-
Hi there, I don't know if this is correct behavior of Yii Active Record, consider I have this code $post = Post::find()
->alias('p')
->select(['p.*', 'COUNT(c.id) AS comment_count'])
->join('LEFT JOIN', 'comments c', 'p.id = c.post_id')
->groupBy('c.id')
->one(); I cannot access // $post from code above
if ($post->comment_count != 0) {
throw new UnprocessableEntityHttpException('Cannot delete post with comment(s)');
}
return $post->delete(); |
Beta Was this translation helpful? Give feedback.
Answered by
bizley
Sep 13, 2022
Replies: 2 comments
-
I guess you would have to add that |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
samdark
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess you would have to add that
comment_count
as a property first.