order_by() 공개 메소드

Sets the ORDER BY value
public order_by ( $orderby, $direction = '' ) : object
리턴 object
예제 #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;
 }
예제 #2
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;
 }
예제 #3
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;
 }
예제 #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;
 }
예제 #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();
 }
예제 #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;
 }
예제 #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;
 }
예제 #8
0
 public function setup_order(CI_DB_active_record $db)
 {
     $db->order_by('annotation.update_timestamp', $this->get_direction());
     return $db;
 }
 /**
  * Inserts custom ORDER BY clausule to given active record and return boolean notification.
  * 
  * @param CI_DB_active_record $db database active record object.
  * @return boolean TRUE, if there is custom order by clause, or FALSE otherwise.
  */
 private function insertOrderByAndNotification(CI_DB_active_record $db)
 {
     if (is_string($this->custom_order_by) && !empty($this->custom_order_by)) {
         if ($this->custom_order_by == 'random') {
             $db->order_by(NULL, 'random');
         } else {
             $db->order_by($this->custom_order_by);
         }
         return TRUE;
     }
     return FALSE;
 }