2016-09-19 3 views
-2

Ich habe ein Problem mit CakePHP3, ich habe 3 Tabelle Benutzer (User_ID, Benutzername, Passwort, E-Mail), Beiträge (Post_ID, User_ID, Content_post) und Kommentar (Kommentar_ID, User_ID, Post_ID), wie ich 3 Tabelle mit Abfrage in CakePHp3 beitreten Danke.Join Tabelle in CakePHP?

+0

Verwenden Sie die MySQL-Abfrage zum Verknüpfen von Tabellen. –

+0

oh ich benutze cakePHP, das mag nicht MySQL: ") –

+0

Wo haben Sie die Details der Benutzer? –

Antwort

0

Überprüfen Sie die Beispielabfrage,

$GroupAccountIds = $this->ClientForm->find(
'list', 
[ 
    'joins' => [ 
     [ 
      'table'=>'group_accounts', 
      'alias' => 'GroupAccount', 
      'type' => 'INNER', 
      'conditions' => [ 
       'ClientForm.created_group_account_id = GroupAccount.group_account_id', 
       'ClientForm.deleted IS NULL' 
      ] 
     ], 
    ], 
    'conditions' => [ 
     'GroupAccount.group_account_category_id' => $smsfCategoryId, 
     'GroupAccount.deleted' => null, 
    ], 
    'fields' => [ 
     'ClientForm.created_group_account_id', 
     'ClientForm.created_group_account_id', 
    ], 
] 

);