获取数据
public function get($count=false,$sql=NULL,$where="",$order="",$group="",$limit=""){
$sql=$sql->where($where)->limit($limit)->group($group)->order($order);
if($count){
if($group!=""){
$list=count($sql);
}else{
$list=$sql->count();
}
}else{
$list=$sql->select();
}
return $list;
}
//用分页的方式取出get的内容
public function pagelist($size=100,$dbsql,$where="",$order="",$group="",$limit=""){
import("ORG.Util.Page");
$count =$this->get(true,$dbsql,$where,$order,$group,$limit);
$Page = new Page($count,$size);
$show = $Page->show();
$list=$this->get(false,$dbsql,$where,$order,$group,$Page->firstRow.','.$Page->listRows);
$this->assign("page",$show);
return $list;
}
调用用方式 $m=M("article");
$sql=$m->field("article.title,article.addtime,article.showtime,article_type.name")->join("join article_type on article.type_id=article.id");
$list=$this->pagelist(10,$sql);
执行的sql语句 为什么是:SELECT COUNT(*) AS tp_count FROM `article` join article_type on article.type_id=article.id LIMIT 1 [ RunTime:0.000458s ]
SELECT * FROM `article` LIMIT 0,10 [ RunTime:0.000460s ]
第二条语句为什么只调用了M("article")而没有调用
->field("article.ti
这个怎么能解决呢?
最佳答案
