$query = (new Query())->select([
'post.id' => 'id',
'post.authorID' => 'authorID',
'post.title' => 'title',
'post.content' => 'content',
])
->distinct()
->from('post')
->leftJoin('comment', '`comment`.`postID` = `post`.`id`')
->where(['comment.authorID' => 1])
->with('comments')
->all();
$subquery = Comments::find()->where('authorID='.$user->id);
$query = Posts::find()
->where(['activateStatus' => 1])
->andWhere(['closedDate' => NULL])
->andWhere(['not exists', $subquery])
->orderBy('price DESC');
$command = $query->createCommand();
echo "<pre>";
var_dump($command->sql);die();
SELECT * FROM `posts` WHERE (`activateStatus`=:qp0) AND (`closedDate` IS NULL) AND (NOT EXISTS (SELECT * FROM `comments` WHERE authorID=1)) ORDER BY `price` DESC