|
楼主 |
发表于 2016-8-26 10:46:23
|
显示全部楼层
本帖最后由 Aloghli 于 2016-8-26 10:47 编辑
public function where($where = NULL, $value = NULL) {
if (isset( $where )) {
$this->_where = FALSE;
if (!is_array($where) && is_null($value)) {
$filter = $this->filter;
$this->db->where($this->primary_key, $filter($where));
} elseif (isset( $value )) {
$this->db->where($where, $value);
} elseif (is_array($where)) {
$this->db->where($where);
}
} else {
if ($this->_where)
$this->db->where($this->_where);
}
return $this;
}
public function or_where($where = NULL, $value = NULL) {
if (isset( $where )) {
$this->_where = FALSE;
if (!is_array($where) && is_null($value)) {
$filter = $this->filter;
$this->db->or_where($this->primary_key, $filter($where));
} elseif (isset( $value )) {
$this->db->or_where($where, $value);
} elseif (is_array($where)) {
$this->db->or_where($where);
}
}
return $this;
}
public function limit($limit = '', $offset = 0) {
if (!$limit) {
if ($this->_limit)
$this->db->limit($this->_limit);
} else {
$this->db->limit($limit, $offset);
}
return $this;
}
public function select($fields = NULL) {
if (isset( $fields )) {
$this->_fields = FALSE;
$fields = ( is_array($fields) ) ? implode(',', $fields) : $fields;
$this->db->select($fields);
} else {
if ($this->_fields) {
$_fields = ( is_array($this->_fields) ) ? implode(',', $this->_fields) : $this->_fields;
$this->db->select($_fields);
}
}
return $this;
}
public function order_by($order_by = '',$rand=false) {
if($rand){
$this->db->order_by($order_by, 'RANDOM');
}else{
if (!$order_by) {
if ($this->_order)
$this->db->order_by($this->_order);
} else {
$this->_order = '';
$this->db->order_by($order_by);
}
}
return $this;
}
public function where_in($fileds = '', $key = '') {
if ($fileds) {
if (!$key) {
$this->db->where_in($this->primary_key, $fileds);
} else {
$this->db->where_in($key, $fileds);
}
}
return $this;
}
public function like($value = '', $key = '', $match = 'both') {
if ($value) {
if (is_array($value) && !$key) {
$this->db->like($value);
} else {
if (!$key) {
$this->db->like($this->primary_key, $value, $match);
} else {
$this->db->like($key, $value, $match);
}
}
}
return $this;
}
public function group_by($group) {
$this->db->group_by($group);
return $this;
}
public function distinct($distinct) {
$this->db->distinct($distinct);
return $this;
}
|
|