Cakephp 3,如何显示连接表

时间:2015-03-26 03:43:57

标签: cakephp-3.0

我有我的桌子  accounts ( id int(10) username password )
和会员表
members ( id account_id first_name last_name e_mail address book_count )
我必须在一个视图中使用INNER join显示两个表,它是如何实现的?

1 个答案:

答案 0 :(得分:1)

阅读HasOne Associations将解决您的问题。

您应该关注Cake tutorial以了解有关cakephp的更多信息

如果您不使用关联,则可以正常使用连接功能

$accounts->join([
    'table' => 'members',
    'alias' => 'mem',
    'type' => 'INNER', //LEFT, RIGHT...
    'conditions' => 'mem.account_id = accounts.id',
])->...