标签:
1.创建视图模型
2.定义视图模型
class BlogViewModel extends ViewModel { public $viewFields = array( ‘Blog‘=>array(‘id‘,‘name‘,‘title‘), ‘Category‘=>array(‘title‘=>‘category_name‘,‘_on‘=>‘Category.id=Blog.category_id‘,‘_type‘=>‘RIGHT‘), ‘User‘=>array(‘name‘=>‘username‘, ‘_on‘=>‘Blog.user_id=User.id‘), ); }
3.数据库语句:
Select Blog.id as id, Blog.name as name, Blog.title as title,
Category.title as category_name,
User.name as username
from think_blog Blog JOIN think_category Category JOIN think_user User where Blog.category_id=Category.id AND Blog.user_id=User.id
标签:
原文地址:http://www.cnblogs.com/subtract/p/4294004.html