thinkphp 多表组合的视图模型
大家好,最近在写一个资产管理系统,但是关于thinkphp的多表视图模型还是有点不太清楚.比如这条语句,=================================...
大家好, 最近在写一个资产管理系统, 但是关于thinkphp的多表视图模型还是有点不太清楚.
比如这条语句,
===================================================================
SELECT c.serial as Serial_Number,c.otherserial as
FA_Number,c.os_license_id as Buy_Date,l.completename as Location,d.name
as Section,m.name as Model,t.name as PC_Type,u.name as GID,u.firstname
as FirstName,u.realname as LastName,s.name as Status
from (((((glpi_computers as c left join glpi_dropdown_domain as d on
c.domain=d.id) left join glpi_dropdown_model as m on c.model=m.id) left
join glpi_dropdown_state as s on c.state=s.id) left join
glpi_type_computers as t on c.type=t.id) left join glpi_users as u on
c.FK_users=u.id) left join glpi_dropdown_locations as l on
c.location=l.id
=====================================================================
在SQL查询中是正常的, 返回我想要的电脑结果
但如果我在视图模型中定义的话, 无从下手, 官方手册只写了两个表之间的left join , 请高手指点一下. 展开
比如这条语句,
===================================================================
SELECT c.serial as Serial_Number,c.otherserial as
FA_Number,c.os_license_id as Buy_Date,l.completename as Location,d.name
as Section,m.name as Model,t.name as PC_Type,u.name as GID,u.firstname
as FirstName,u.realname as LastName,s.name as Status
from (((((glpi_computers as c left join glpi_dropdown_domain as d on
c.domain=d.id) left join glpi_dropdown_model as m on c.model=m.id) left
join glpi_dropdown_state as s on c.state=s.id) left join
glpi_type_computers as t on c.type=t.id) left join glpi_users as u on
c.FK_users=u.id) left join glpi_dropdown_locations as l on
c.location=l.id
=====================================================================
在SQL查询中是正常的, 返回我想要的电脑结果
但如果我在视图模型中定义的话, 无从下手, 官方手册只写了两个表之间的left join , 请高手指点一下. 展开
1个回答
展开全部
class BlogViewModel extends ViewModel {
public $viewFields = array(
'Blog'=>array('id','name','title'),
'Category'=>array('title'=>'category_name', '_on'=>'Blog.category_id=Category.id'),
'User'=>array('name'=>'username', '_on'=>'Blog.user_id=User.id'),
);
}
其实可以进行多表的,
public $viewFields = array(
'Blog'=>array('id','name','title'),
'Category'=>array('title'=>'category_name', '_on'=>'Blog.category_id=Category.id'),
'User'=>array('name'=>'username', '_on'=>'Blog.user_id=User.id'),
);
}
其实可以进行多表的,
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询