select() public method

Generates the SELECT portion of the query
public select ( $select = '*', $escape = NULL ) : object
return object
Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public function setup_order(CI_DB_active_record $db)
 {
     $db->select('ts_rank_cd(annotation.note_index, "search_anchor_text_query") AS search_anchor_text_rank', FALSE);
     $db->order_by('search_anchor_text_rank', $this->get_direction());
     //$db->order_by('ts_rank_cd(search_anchor_text.indexed, search_anchor_text_query, 1)', $this->get_direction());
     return $db;
 }
Ejemplo n.º 5
0
 /**
  * 批量读取数据
  * @param array|string $where 条件
  * @param string $order 排序字段
  * @param int $limit 查询数量
  * @param int $offset 查询起始偏移量
  * @return array
  */
 public function fetchAll($cols = '*', $where, $order, $limit = NULL, $offset = NULL)
 {
     $this->db->select($cols);
     $this->where($where);
     if (!empty($order)) {
         $this->db->order_by($order);
     }
     return $this->db->get($this->_name, $limit, $offset)->result_array();
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
 private final function _generate_related_sql()
 {
     foreach ($this->_related_sql as $Fn => $Content) {
         foreach ($Content as $Query => $Data) {
             if (is_array($Data)) {
                 //Its a join or similar
                 list($Table, $Condition, $Type) = $Data;
                 if ($this->_selectAllFromTables) {
                     $this->db->select($Table . '.*');
                 }
                 $this->db->{$Fn}($Table, $Condition, $Type);
             } elseif (is_string($Data)) {
                 //Simple query, like a where
                 $this->db->{$Fn}($Query, $Data);
             } else {
                 $this->db->{$Fn}($Query);
             }
         }
     }
     $this->_related_sql = array();
 }
 /**
  * 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');
     }
 }