实际开发中,遇到一个问题,像下面的代码:
/* 获取明细列表 */
public function getMoneyList($whereArr, $offset=0, $perpage=10, $order='', $orderVal='') {
    $result = ARRAY();
    $this->CI->db->select('id,money,add_time,user_id,user_account,category_id,note,score_id,update_time');
    if (!empty($order) && !empty($orderVal) ) $this->CI->db->order_by($order, $orderVal);
    if (!empty($whereArr)) $this->CI->db->where($whereArr);
    if (!empty($perpage)) $this->CI->db->limit($perpage, $offset);
    $query = $this->CI->db->get('om_detail');
    if ($query->num_rows() == 0) return $result;
    foreach ($query->result_array() as $row)
        $result[$row['id']] = $row;
    return $result;
}这是一个获取明细列表的方法,只要传递条件数组、偏移量、分页、及排序和值就可以将所需要的明细返回过来。
 继续阅读 CI数据库操作 如何写where 中的 where_in →