zoukankan      html  css  js  c++  java
  • get_list_by_where

     /**
         * 查询数据
         * @param $param
         * @param bool $get_rows 或者总数
         * @param bool $get_one 或者一条记录
         * @param bool $master 是否主表查询
         */
        public function get_list_by_where(array $params, $get_rows = false, $get_one = false,$master=false)
        {
            $this->db->from($this->table);
            if (isset($params['select'])) {
                if (isset($params['select_escape'])) {
                    $this->db->select($params['select'], false);
                } else {
                    $this->db->select($params['select']);
                }
            }
    
            if($master){
                $this->db->force_master();
            }
            if (isset($params['where']) && is_array($params['where'])) {
                $this->db->where($params['where']);
            }
    
            if (isset($params['where_in']) && is_array($params['where_in'])) {
                $this->db->where_in($params['where_in']['key'], $params['where_in']['value']);
            }
    
            if (isset($params['join'])) {
                foreach ($params['join'] as $item) {
                    $this->db->join($item['table'], $item['where'], $item['type']);
                }
            }
            if (isset($params['limit'])) {
                if (is_array($params['limit']) && isset($params['limit']['page']) && isset($params['limit']['page_size'])) {
                    $this->db->limit($params['limit']['page_size'],($params['limit']['page']-1)*$params['limit']['page_size']);
                } else {
                    $this->db->limit($params['limit']);
                }
            }
    
            if (isset($params['group'])) {
                $this->db->group_by($params['group']);
            }
            if (isset($params['order'])) {
                if (is_array($params['order'])) {
                    foreach ($params['order'] as $v) {
                        $this->db->order_by($v['key'], $v['value']);
                    }
                } else {
                    $this->db->order_by($params['order']);
                }
    
            }
    
            $result = $this->db->get();
            if (!$get_one) {
                return $get_rows ? $result->num_rows() : ($result->num_rows() > 0 ? $result->result_array() : array());
            } else {
                return $get_rows ? $result->num_rows() : ($result->num_rows() > 0 ? $result->row_array() : array());
            }
        }
    

      

  • 相关阅读:
    Vue实现添加、删除、关键字查询
    打开新页面 自定义方法并获取携带值
    unity3d 刷新速率
    unity3d AssetStore 下载的资源位置
    unity3d c# http 请求json数据解析
    unity3d 自定义载入条/载入动画
    课程改进意见
    梦断代码
    An internal error occurred during: "Launching MVC on Tomcat 7.x".
    n以内的1的个数
  • 原文地址:https://www.cnblogs.com/brady-wang/p/9591514.html
Copyright © 2011-2022 走看看