Using where params in beforefind |
I'm trying to use beforefind callback in ci4 BaseModel because I want to get comment like numbers for a specified post
To get post comments I'm using the normal findAll PHP Code: $comment_model->where('post_id', $post_id)->orderBy('id', 'desc')->findAll(); To show like numbers for each comment, I want to modify the findAll result using a callback in beforeFind PHP Code: //... It works when I wants to get all, but when I get with condition, PHP Code: $model->where('post_id', 1)->findAll(); How do you think I can get where parameters inside that callback? For now I'm using afterFind callback looping each result but that is too many queries. PHP Code: protected function afterFindWithLikesNum($eventData) Thank you |
Messages In This Thread |
Using where params in beforefind - by heriniaina - 06-11-2022, 05:51 AM
RE: Using where params in beforefind - by iRedds - 06-11-2022, 08:07 PM
|