This is the platform-independent base Active Record implementation class.
Author: ExpressionEngine Dev Team
Inheritance: extends CI_DB_driver
コード例 #1
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;
 }
コード例 #2
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;
 }
コード例 #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;
 }
コード例 #4
0
ファイル: Search_order_like.php プロジェクト: 119155012/kals
 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;
 }
コード例 #5
0
ファイル: Search_order_score.php プロジェクト: 119155012/kals
 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;
 }
コード例 #6
0
ファイル: MY_Model.php プロジェクト: taquimon/rhc
 /**
  * If the result provided is not valid it will throw and exception
  * and the rollback any database transaction in progress
  * @param type $result
  * @return type
  * @throws Exception
  */
 function validateDBTransactionResult($result)
 {
     if (!$result) {
         $errorMessage = "Error de base de datos - " . $this->db->_error_message();
         $this->db->trans_rollback();
         throw new Exception($errorMessage);
     }
     return;
 }
コード例 #7
0
ファイル: ifx_Model.php プロジェクト: Swift-Jr/thmdhc
 /**
  * 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;
 }
コード例 #8
0
ファイル: Search_order_scope.php プロジェクト: 119155012/kals
 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;
 }
コード例 #9
0
ファイル: CU_Model.php プロジェクト: syalr/vitime-meeting
 /**
  * 重写where
  * @param mixed $where
  * return CU_Model $this->db
  */
 protected function where()
 {
     $args = func_get_args();
     if (is_array($args[0])) {
         foreach ($args[0] as $k => $wh) {
             if (is_array($wh)) {
                 $this->db->where_in($k, $wh);
             } else {
                 $this->db->where($k, $wh);
             }
         }
     } else {
         if (empty($args[0])) {
             return $this->db;
         }
         call_user_func_array(array($this->db, 'where'), $args);
     }
     return $this->db;
 }
コード例 #10
0
ファイル: Generic_collection.php プロジェクト: 119155012/kals
 /**
  * 預設搜尋條件
  *
  * 預設會搜尋$index_field中符合$id的資料
  * 子類別如有必要請覆寫此方法
  * @param CI_DB_active_record $db
  * @param integer $id
  */
 protected function _load_default_index_where(CI_DB_active_record $db, $id)
 {
     $db->where($this->table_name . '.' . $this->index_field, $id);
 }
コード例 #11
0
 /**
  * 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');
     }
 }
コード例 #12
0
ファイル: DB.php プロジェクト: wiserweb/OpenVBX
 protected function _flush()
 {
     $this->_db->truncate($this->_table);
 }
コード例 #13
0
 public function setup_order(CI_DB_active_record $db)
 {
     $db->order_by('annotation.update_timestamp', $this->get_direction());
     return $db;
 }
コード例 #14
0
 /**
  * Like
  *
  * Called by like() or orlike()
  *
  * @access    private
  * @param    mixed
  * @param    mixed
  * @param    string
  * @return    object
  */
 function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
 {
     // store this as the last_bracket_type
     $this->last_bracket_type = 'like';
     // do we already have entries for the where clause?
     if ($where_count = count($this->ar_where) > 0) {
         // yes, add a dummy entry to force the $type being added
         $this->ar_like[] = '';
     }
     // call the original method
     $result = parent::_like($field, $match, $type, $side, $not);
     // fetch the key of the last entry added
     end($this->ar_like);
     $key = key($this->ar_like);
     // do we need to add an open bracket
     if ($this->ar_bracket_open) {
         // was this the first entry?
         if ($where_count == 0) {
             // first where clause, simply prefix it with a bracket open
             $this->ar_like[$key] = '(' . $this->ar_like[$key];
         } else {
             // subsequent where clause, strip the type before adding the bracket open
             $this->ar_like[$key] = $type . ' (' . substr($this->ar_like[$key], strlen($type));
         }
         // reset the bracket state
         $this->ar_bracket_open = FALSE;
         if ($this->ar_caching === TRUE) {
             $this->ar_cache_like[$key] = $this->ar_like[$key];
         }
     }
     // add the like to the ar_where array to maintain where clause sequence
     $this->ar_where[] = $this->ar_like[$key];
     $this->ar_like = array();
     // return the result
     return $result;
 }
コード例 #15
0
 /**
  * Replaces first found question mark with given value using given database active record class.
  * 
  * @param string $where where clausule to be altered.
  * @param mixed $value value, to be replacet against first question mark from left.
  * @param CI_DB_active_record $db database active record object.
  * @return string altered where clausule.
  */
 private function replaceFirstQuestionMark($where, $value, CI_DB_active_record $db)
 {
     $escaped_value = $db->escape($value);
     $index = strpos($where, '?', 0);
     if ($index !== FALSE) {
         return substr($where, 0, $index) . $escaped_value . substr($where, $index + 1);
     }
     return $where;
 }