Welcome to Delicate template
Header
Just another WordPress site
Header

thinkphp视图模型多表查询

2月 25th, 2014 | Posted by 无 名 in php | thinkphp

做个笔记,代码如下:

class ArticleViewModel extends ViewModel {
    //文章表视图模型
    public $viewFields = array(
        'article'=>array('id', 'title', 'cid', 'post_time', 'visitors'),
        'category'=>array('cname', '_on'=>'article.cid=category.id', '_type'=>'LEFT'),    //文章分类表,在关联模型里面属于BELONGS_TO
        'pl'=>array('pl1', 'pl2', '_on'=>'article.id=pl.aid', '_type'=>'LEFT'),    //评论表,在关联模型里面属于HAS_ONE
        'tz'=>array('id'=>'tz_id', '_on'=>'article.id=tz.aid', '_type'=>'LEFT')    //投资表,在关联模型里面属于HAS_ONE
    );
}

实现多表查询

You can follow any responses to this entry through the RSS 2.0 Both comments and pings are currently closed.