作者:好宝贝蛋_282 | 来源:互联网 | 2018-04-24 22:09
classUserModelextendsRelationModel{$_linkarray{'foreign_key'>'deptId','class_name'>'dept','as_fields'>'dept_name,dept_phone','mapping_type'>BELONGS_TO}}User表中有deptI
关联查询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();//这句的第二个条件就不能起作用了