Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Conditional clauses in ORM query.
  • Hi

    I'm trying to create a filterable list of objects, where the filter options are set by the user and passed in as GET vars.

    This query works as expected...

    $t = Model_Task::query()->where('status_id', Input::get('s'))->get();

    but obviously if the user doesn't want the list filtered by status, then I need that where clause to not be included. So I tried this...

    $t = Model_Task::query();
        $t->where('status_id', (integer)Input::get('s'));

    But this throws the error...

    Object class "Orm\Query" could not be converted to string or sanitized as ArrayAccess. Whitelist it in security.whitelisted_classes in app/config/config.php to allow it to be passed unchecked.

    Which suggests to me that the get() method isn't doing what I think it should be doing. Is there an elegant way of handling this?

  • Sorry, ignore me. Stupid error.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion