Можете ли вы помочь мне с CakePHP код запроса.Мне удалось сделать код MySQL , но я не смог преобразовать его в CakePHP
Вот MySQL код
SELECT team_name, count(team_members.id)
FROM teams
LEFT JOIN team_members ON teams.id = team_members.team_id
WHERE teams.user_id = 15
GROUP BY teams.id
и вот как я пытался получить код от CakePHP :
$email = $this->request->getQuery('email');
$user = $this->Users
->find('all')
->where(['email' => $email])->first();
$options = array(
'joins' =>
array(
array(
'table' => 'TeamMembers',
'alias' => 'TeamMembers',
'type' => 'left',
'foreignKey' => false,
'conditions'=> array('TeamMembers.team_id = Teams.id')
),
),
);
$teams = $this->Teams->find('all', $options)
->select(["team_name","id",'count_members' => 'count(*)'])
->where(['Teams.user_id' => $user->id])
->group(['Teams.id']);