if412010
if412010

Reputation: 347

Cakephp 3, how to show joined table

i have my table
accounts ( id int(10) username password )
and members table
members ( id account_id first_name last_name e_mail address book_count )
i have to show both of the tables in one view with INNER join, how it can be possible?

Upvotes: 0

Views: 1221

Answers (1)

Giang Nguyễn
Giang Nguyễn

Reputation: 46

Read HasOne Associations will solve your problem.

You should follow Cake tutorial to know more about cakephp

If you don't use associations you can do normally with join function

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

Upvotes: 1

Related Questions