2017-07-28 19 views
1
$table = TableRegistry::get('Leads'); 
$query = $table->find('all')->leftJoinWith('LeadStatus')->contain(['Users', 'LeadStatus' => 
function ($q) 
    { 
    return $q->contain(['LeadBuckets', 'LeadBucketSubStatus'])->where(['LeadStatus.is_active' => 1]); 
    } 

])->where(['Leads.sub_agent_id' => $subAgentId]); 

に参加する方法へのユーザーこれは私がテーブルlead_statusからテーブルleadsのために参加し、左使用しています私のクエリです。今、同じクエリで第3テーブルassigned_leadsの左結合を使用したいと思います。2つの左は、CakePHP 3.xので

leadslead_statusとの結合を試みました。assigned_leadsです。私はcakephp 3.xを使用しています。これをどのようにすることができますか?

私は、以下のように参加し、左使用してこれを解決した

答えて

0

$query = $table->find('all')->leftJoinWith('LeadStatus') 
      ->leftJoinWith('AssignedLeads') 
      ->contain(['AssignedLeads'=>'Users','LeadStatus' => function($q) 
       { 
        return $q->contain(['LeadBuckets', 'LeadBucketSubStatus']) 
        ->where(['LeadStatus.is_active' => 1]); 
       } 
       ]) 
      ->where(['Leads.sub_agent_id' => $subAgentId]) 
      ->where(['AssignedLeads.user_id IN' => $userId]); 
関連する問題