5154

Good Luck To You!

thinkphp如何关联查询

### 使用withJoin方法,,``,$result = Db::table('a'), >withJoin('b', function($query) {, $query>where('a.id', '=', 'b.a_id');, }), >select();,`,,### 使用关联模型,,`,class User extends Model,{, public function orders(), {, return $this>hasMany(Order::class, 'user_id', 'id');, },},,$user = User::find(1);,foreach ($user>orders as $order) {, echo $order>name;,},``
<< 1 >>
«    2025年9月    »
1234567
891011121314
15161718192021
22232425262728
2930
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
    文章归档
    网站收藏
    友情链接

    Powered By Z-BlogPHP 1.7.3

    Copyright Your WebSite.Some Rights Reserved.