public function setup_order(CI_DB_active_record $db) { $db->join('annotation2scope AS order_annotation2scope', 'order_annotation2scope.annotation_id = annotation.annotation_id'); $db->join('scope AS order_scope', 'order_scope.scope_id = order_annotation2scope.scope_id'); if ($this->desc === TRUE) { $db->select('order_scope.to_index'); $db->order_by('order_scope.to_index', $this->get_direction()); } else { $db->select('order_scope.from_index'); $db->order_by('order_scope.from_index'); } return $db; }
public function setup_order(CI_DB_active_record $db) { $db->join('annotation2respond_count AS order_respond', 'order_respond.annotation_id = annotation.annotation_id'); $db->select('order_respond.responded_count'); $db->order_by('order_respond.responded_count', $this->get_direction()); return $db; }
public function setup_order(CI_DB_active_record $db) { $db->join('user AS order_user', 'order_user.user_id = annotation.user_id'); $db->select('order_user.name'); $db->order_by('order_user.name', $this->get_direction()); return $db; }
public function setup_order(CI_DB_active_record $db) { // $db->select('(SELECT count(user_id) ' // . 'FROM annotation2like JOIN annotation ON annotation2like.annotation.id = annotation.annotation.id) ' // . 'GROUP BY annotation_id WHERE annotation.annotation_id'); $db->join('annotation2like_count AS order_like', 'order_like.annotation_id = annotation.annotation_id '); $db->select('order_like.like_count'); $db->order_by('order_like.like_count', $this->get_direction()); return $db; }
/** * Generates a join statement for use with update_join and delete($join) * * @param mixed $join_table * @param mixed $join_field * @param mixed $join_type */ private final function _forge_join($JoinObject, $JoinType = 'INNER') { //Meeds to work out join types //Prepare the join $this->db->join($JoinObject->_table(), $JoinObject->_table() . '.' . $this->_id() . '=' . $this->_table() . '.' . $this->_id(), $JoinType); $JoinStatement = implode(' ', $this->db->ar_join); //Clear the CI_AR so we dont duplicate the join in any AR query $this->db->ar_join = array(); //Set the forged join $this->_forged_join = $this->_forged_join() . ' ' . $JoinStatement; }
public function setup_order(CI_DB_active_record $db) { //$CI =& get_instance(); //$CI->load->library('score/Annotation_score_integrated'); //$score_type_id = $CI->annotation_score_integrated->get_type_id(); //$db->join('score AS order_score', 'order_score.annotation_id = annotation.annotation_id AND order_score.score_type_id = '.$score_type_id); $db->join('annotation2score AS order_score', 'order_score.annotation_id = annotation.annotation_id'); $db->select('order_score.score'); $db->order_by('order_score.score', $this->get_direction()); return $db; }
/** * load_default()的自訂追加條件 * * Generic_association_collection中加入了外鍵關連的設定。 * 在Generic_collection的成員是取得自身$table_name的資料來建立成員。 * 但Generic_association_collection則是取得$class_name_table資料表中的資料來建立成員。 * @param CI_DB_active_record $db * @param int $id */ protected function _load_custom(CI_DB_active_record $db = NULL, $id = NULL) { //$db = $this->db; $class_table_name = $this->class_table_name; if ($this->table_name != $class_table_name) { $db->join($class_table_name, $this->table_name . '.' . $this->foreign_field . ' = ' . $class_table_name . '.' . $this->class_foreign_field); } else { $class_table_name = 'association'; $db->join($this->class_table_name . ' AS ' . $class_table_name, $this->table_name . '.' . $this->foreign_field . ' = ' . $class_table_name . '.' . $this->class_foreign_field); } $db->select($class_table_name . '.*'); if (isset($this->class_fake_delete)) { $db->where($class_table_name . '.' . $this->class_fake_delete, 'FALSE'); } }