yii2 中的 LEFT 加入 AND 命令

LEFT join AND command in yii2

我想在yii2中写一个查询 我不知道怎么写 我尝试了 documentaion 中的一些东西,但它不起作用 这是我的查询

SELECT notification.*,event.title,user.firstname,user.lastname FROM notification 
LEFT JOIN event ON event.id = notification.source_id 
AND notification.activity_type = "checkin"
Where user.firstname in (select id from user where user_id=1) 
LEFT JOIN user ON user.id = notification.source_id 
AND notification.activity_type = "friend" 
Where user.firstname in (select id from user where user_id=1)

这是我现在写的查询,我需要像在查询中一样添加 AND 函数

    $query  ->select(['notification.*,event.title,user.firstname,user.lastname'])
            ->from('notification')
            ->leftJoin('event', 'event.id = notification.source_id')
            ->leftJoin('user', 'user.id = notification.source_id');

您是否尝试过以下方法:

$query  ->select(['notification.*,event.title,user.firstname,user.lastname'])
            ->from('notification')
            ->leftJoin('event', 'event.id = notification.source_id AND notification.activity_type = "checkin" ')
            ->leftJoin('user', 'user.id = notification.source_id AND notification.activity_type = "friend"');