where() публичный Метод

Generates the WHERE portion of the query. Separates multiple calls with AND
public where ( $key, $value = NULL, $escape = TRUE ) : object
Результат object
Пример #1
0
 /**
  * The actual function used for updating or interting a record
  *
  * @return bool
  */
 private final function _save_row()
 {
     //First run validation, and bail out if it fails
     if ($this->validate() == FALSE) {
         return FALSE;
     }
     $this->_set_row();
     if ($this->_isnew) {
         $this->db->insert($this->_table());
         $this->_data[$this->_id()] = $this->db->insert_id();
         $Return = $this->id() != NULL;
         if ($Return == true) {
             $this->_isnew = false;
             $Record = new stdClass();
             foreach ($this->_data as $K => $V) {
                 $Record->{$K} = $V;
             }
             $this->_original_record = $Record;
         }
         return $Return;
     } else {
         $this->db->where($this->_id(), $this->id());
         $this->db->update($this->_forged_join());
         //Just in case  a join has been forged
         $this->_clear_forged_join();
         if ($this->_record_is_changed()) {
             return $this->db->affected_rows() > 0;
         }
         return true;
     }
 }
Пример #2
0
 /**
  * 重写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;
 }
Пример #3
0
 /**
  * 預設搜尋條件
  *
  * 預設會搜尋$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);
 }
 /**
  * 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');
     }
 }
Пример #5
0
 protected function _invalidate($group, $tenant_id)
 {
     // delete the group from the db
     $this->_db->where('group', $group)->where('tenant_id', $tenant_id)->delete($this->_table);
     return true;
 }