How can I filter discussions by Name using existing Models?
Neither the DiscussionModel nor the model implement the like() method from the SQL driver which would allow filtering by names. But the SQL driver is accessible through the DiscussionModel. Therefore you can do it like that:
$discussionModel = DiscussionModel::instance(); $discussionModel->SQL->like('Name', '%test%'); $discussions = $discussionModel->get(0, 10); foreach($discussions as $discussion) { echo $discussion->Name.'<br>'; }
This way you directly add the "like" to the query builder before the get() method starts doing its work. 😉
get()
Thanks a lot!
See the FilterDiscussion plugin and specifically at the LK parameter.
Comments
Neither the DiscussionModel nor the model implement the like() method from the SQL driver which would allow filtering by names. But the SQL driver is accessible through the DiscussionModel. Therefore you can do it like that:
This way you directly add the "like" to the query builder before the
get()
method starts doing its work. 😉Thanks a lot!
See the FilterDiscussion plugin and specifically at the LK parameter.