zoukankan      html  css  js  c++  java
  • swoole gets

    控制器调用:

        function gets()
        {
            $model = Model('ap_pic');
            $model->select = ' id, size_type ';
            $gets['page'] = empty($_GET['page'])?0:intval($_GET['page']);
            $gets['pagesize'] = 2;
            $gets['where'] = " orders=1381392612 ";
            $gets['orwhere'] = " name=1381392612 ";        
            $pager = 2;
            $list = $model->gets($gets, $pager);
            echo "<pre>";
            var_dump($list);
            echo "</pre>";
            exit;
        }

    调用了Model.php

        /**
         * 获取表的一段数据,查询的参数由$params指定
         * @param $params
         * @param $pager Pager
         * @return Array
         */
        public final function gets($params, &$pager=null)
        {
            if (empty($params))
            {
                throw new Exception("no params.");
            }
    
            $selectdb = new SelectDB($this->db);
            $selectdb->from($this->table);
            $selectdb->primary = $this->primary;
            $selectdb->select($this->select);
    
            if (!isset($params['order']))
            {
                $params['order'] = "`{$this->table}`.{$this->primary} desc";
            }
            $selectdb->put($params);
    
            if (isset($params['page']))
            {
                $selectdb->paging();
                $pager = $selectdb->pager;
            }
    
            return $selectdb->getall();
        }

    selectDB.php中 function put($params)

        /**
         * 将数组作为指令调用
         * @param $params
         * @return null
         */
        function put($params)
        {
            if(isset($params['put']))
            {
                Error::info('SelectDB Error!','Params put() cannot call put()!');
            }
            //处理where条件
            if(isset($params['where']))
            {
                $wheres = $params['where'];
                if(is_array($wheres)) foreach($wheres as $where) $this->where($where);
                else $this->where($wheres);
                unset($params['where']);
            }
            //处理orwhere条件
            if(isset($params['orwhere']))
            {
                $orwheres = $params['orwhere'];
                if(is_array($orwheres)) foreach($orwheres as $orwhere) $this->orwhere($orwhere);
                else $this->$orwheres($orwheres);
                unset($params['orwhere']);
            }
            //处理walk调用
            if(isset($params['walk']))
            {
                foreach($params['walk'] as $call)
                {
                    list($key,$value) = each($call);
                    $this->_call($key,$value);
                }
                unset($params['walk']);
            }
            //处理其他参数
            foreach($params as $key=>$value)
            {
                $this->_call($key,$value);
            }
        }
  • 相关阅读:
    Pandas系列
    Pandas快速入门
    Pandas数据结构
    机器学习三剑客之Matplotlib
    机器学习三剑客之Pandas
    机器学习三剑客之Numpy
    NumPy IO文件操作
    NumPy使用 Matplotlib 绘制直方图
    nyoj 37 回文字符串
    判断一个字符串是不是回文串
  • 原文地址:https://www.cnblogs.com/agang-php/p/4523932.html
Copyright © 2011-2022 走看看