当前位置:Gxlcms > PHP教程 > 关于thinkphp框架的关联查询RealtionModel

关于thinkphp框架的关联查询RealtionModel

时间:2021-07-01 10:21:17 帮助过:15人阅读

关联查询thinkphpphp

class UserModel extends RelationModel{
$_link = array{
'foreign_key'=>'deptId',
'class_name'=>'dept',
'as_fields'=>'dept_name,dept_phone',
'mapping_type'=>BELONGS_TO
}
}
User表中有deptId外键,
$U = new UserModel();
$U->relation(true)->where("username = 'Lucy'")->select();//可以起作用
$U->relation(true)->where("username = 'Lucy' and dept_phone = '123456'")->select();//这句的第二个条件就不能起作用了

人气教程排行