M方法疑惑 变量定义 求帮助

浏览:531 发布日期:2013/07/28 分类:求助交流 关键字: M方法 变量定义
获取数据
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.title,article.addtime,article.showtime,article_type.name")->join("join article_type on article.type_id=article.id");呢
这个怎么能解决呢?
最佳答案
评论( 相关
后面还有条评论,点击查看>>