php 資料庫類

來源:互聯網
上載者:User

 +----------------------------------------------------------
         * @param mixed $where 資料
         * @param string $tables  資料表名
         * @param string $fields  欄位名
         * @param string $order  排序
         * @param string $limit
         * @param string $group
         * @param string $having
         * @param boolean $cache 是否緩衝
         * @param boolean $lazy 是否惰性載入
         * @param boolean $lock 是否加鎖
         +----------------------------------------------------------
         * @return ArrayObject
         +----------------------------------------------------------
         * @throws ThinkExecption
         +----------------------------------------------------------
         */
        public function find($where,$tables,$fields='*',$order=null,$limit=null,$group=null,$having=null,$join=null,$cache=false,$lazy=false,$lock=false)
        {
                if(in_array($this->getDbType(),array('MSSQL','IBASE'),true) ) {
                        $this->queryStr = 'SELECT '.$this->parseLimit($limit)
                        .$this->parseFields($fields)
                        .' FROM '.$tables
                        .$this->parseJoin($join)
                        .$this->parseWhere($where)
                        .$this->parseGroup($group)
                        .$this->parseHaving($having)
                        .$this->parseOrder($order);
                }else{
                        $this->queryStr = 'SELECT '.$this->parseFields($fields)
                        .' FROM '.$tables
                        .$this->parseJoin($join)
                        .$this->parseWhere($where)
                        .$this->parseGroup($group)
                        .$this->parseHaving($having)
                        .$this->parseOrder($order);
                        if("ORACLE" == $this->getDbType())
                                if($limit[0] <= 0){
                                        if($limit[1] > 0)
                                                $this->queryStr = "SELECT * FROM (".$this->queryStr.") WHERE ROWNUM <= ".$limit[1];
                                }else{
                                        $whereClause = "";
                                        if($limit[1] > 0)
                                                $whereClause = " WHERE ROWNUM <= ".($limit[0] + $limit[1]);

                                        $this->queryStr = "SELECT * FROM ( SELECT ROW_.*, ROWNUM ROWNUM_ FROM ("
                                                                          .$this->queryStr.") ROW_"
                                                                          .$whereClause
                                                                          .") WHERE ROWNUM_ > "
                                                          .$limit[0];
                                }
                        else
                                $this->queryStr .= $this->parseLimit($limit);
                }
                return $this->query('',$cache,$lazy,$lock);
        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.