HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Filter discussion by Name

How can I filter discussions by Name using existing Models?



  • Options
    R_JR_J Ex-Fanboy Munich Admin

    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. 😉

  • Options

    Thanks a lot!

  • Options
    rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    See the FilterDiscussion plugin and specifically at the LK parameter.

Sign In or Register to comment.