public static function get_member_ids($member_id, $relation_type = null, $target_col = 'member_id_to') { $where_col = $target_col == 'member_id_to' ? 'member_id_from' : 'member_id_to'; if (substr($relation_type, 0, 3) != 'is_') { $relation_type = 'is_' . $relation_type; } if ($relation_type && !in_array($relation_type, array('is_follow', 'is_friend', 'is_access_block'))) { throw new InvalidArgumentException('Second parameter is invalid.'); } $query = \DB::select($target_col)->from(self::$_table_name)->where($where_col, $member_id); if ($relation_type) { $query = $query->and_where($relation_type, 1); } $result = $query->execute()->as_array(); return \Util_db::conv_col($result); }
public static function get_album_image4note_id($note_id, $limit = 0, $sort = array('id' => 'asc'), $with_count_all = false) { $album_image_ids = \Util_db::conv_col(\DB::select('album_image_id')->from('note_album_image')->where('note_id', $note_id)->execute()->as_array()); if (!$album_image_ids) { return $with_count_all ? array(array(), 0) : array(); } $query = \Album\Model_AlbumImage::query()->related(array('album'))->where(array('id', 'in', $album_image_ids)); if ($with_count_all) { $count_all = $query->count(); } if ($sort) { foreach ($sort as $column => $order) { $query->order_by($column, $order); } } if ($limit) { $query->rows_limit($limit); } $list = $query->get(); return $with_count_all ? array($list, $count_all) : $list; }
public static function get_ids4thread_id($thread_id, $order_by = 'id') { $result = \DB::select('id')->from('thread_image')->where('thread_id', $thread_id)->order_by($order_by, 'asc')->execute()->as_array(); return \Util_db::conv_col($result); }
public static function get_timeline_ids4foreign_table_and_foreign_id($foreign_table, $foreign_id) { return \Util_db::conv_col(\DB::select('timeline_id')->from('timeline_child_data')->where('foreign_table', $foreign_table)->where('foreign_id', $foreign_id)->group_by('timeline_id')->execute()->as_array()); }