tp3.2的视图类问题

浏览:780 发布日期:2017/05/05 分类:求助交流 关键字: viewmodel
写了一个视图类class ArcViewModel extends ViewModel{
    protected $viewFields=array();
    public function _initialize(){
        $this->getOtherTable();
    }
    public function getOtherTable($tableN='article'){

        $this->tableName=$tableN;
        $this->viewFields=array(
            $this->tableName=>array('*','_type'=>'LEFT'),
            'category'=>array(
                'id'=>'categoryid',
                'name'=>'catename',
                '_on'=>$this->tableName.'.cid=category.id'),
        );
        return $this;
    }
}
因为有时候可能不是同一个表和category表联合查询,所以想写成动态使用的,调用的时候直接写$list1 = D('ArcView')->getOtherTable('product')->select();
在不同的方法里这样可以成功,但是放在一个方法里就出错了,
$list1 = D('ArcView')->getOtherTable('product')->select();
$list2 = D('ArcView')->getOtherTable('article')->select();
这样就直接报错,打印出来的sql语句,FROM xyh_product product LEFT JOIN xyh_category category ON product.cid=category.id
表名xyh_product和on条件这里都没被改变,还是第一条语句值,实在想不明白什么问题,我这样写是不是不行的?
最佳答案
评论( 相关
后面还有条评论,点击查看>>