有一个
user表存储用户主体信息
user_profile表存储用户资料
user_category放用户分类信息code
如今想实现经过user表查询到关联表user_profile的信息,同时显示user_profile中用户的分类详情。也就是嵌套关联:ip
array (size=17) 'id' => int 80 'nickname' => string '用户昵称' (length=15) 'password' => null 'from_where' => int 1 'status' => int 1 'profile' => array (size=16) 'id' => int 7 'name' => string '张三' (length=6) 'entry_time' => string '2010-09-23' (length=10) 'cate_id' => int 5 'position' => string '经理' (length=6) 'update_time' => null 'category' => array (size=6) 'id'=>2, 'name'=>'vip用户'
只需这么写:string
$userList=$userList->limit($start,$count)->order('create_time desc')->with('profile,profile.category')->select(); return $userList;