php 数据库类
<?php /* +---------------------------------------------------------- * @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); }
本文地址:http://www.phprm.com/code/e59cd890acb73c11211a783e931ddfdd.html
转载随意,但请附上文章地址:-)