|
在数据库查询的一个models里面,代码如下
PHP复制代码 function getInfoByArr ($wherearr,$orderstr="",$pagenum){
$this->load->database();
$this->db->select('id,bookname, author, isbn, press, out_date, price, sort_name');
//设置查询条件
if ($wherearr['bookname'] != '')
$this->db->where('bookname',$wherearr['bookname']);
if ($wherearr['isbn'] != '')
$this->db->where('isbn',$wherearr['isbn']);
if ($wherearr['sort_id'] != "")
$this->db->where_in('sort_id',split(",",$wherearr['sort_id']));
if ($wherearr['author'] != '')
$this->db->where('author',$wherearr['author']);
if ($wherearr['price1'] != 0 and $wherearr['price2'] != 0){
$this->db->where('price >',$wherearr['price1']);
$this->db->where('price <',$wherearr['price2']);
}
//设置排序条件
if ($orderstr != "")
$this->db->order_by($orderstr,"desc");
$this->db-limit ($pagenum,20) ;
$query = $this->db->get('t_book');
if ($query->num_rows()>0) {
$result = $query->result_array();
return $result;
}else {
return "";
}
} 复制代码
让人很奇怪的是这句:
$this->db-limit($pagenum,20) ; //只要加上这个设置limit就查不出数据,只要把这句去掉就正常,为什么很郁闷
去掉这句,改写成$query = $this->db->get('t_book',$pagenum,20);也不行,还是查不出数据,为啥呢
[ 本帖最后由 gz123 于 2008-10-22 15:29 编辑 ] |
|