thinkphp5.1關聯模型 中的字段須要再次關聯查詢

有一個
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;
相關文章
相關標籤/搜索