Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to use MySQL functions in 'where' section
  • I want to use MySQL function in where section.
    For example:

    $q = Model_Foo::query()->where(DB::expr('YEAR(birthday)'), '=', 1980);
    * `birthday` field type is datetime.

    But this code doesn't works. It returns ErrorException 4096.
    How should I do? Please help.
    I'm using ver. 1.5

  • I'm not sure DB::expr() was supported in where() clauses back in 1.5.

    What is the exact error message you get?
  • Thanks to your response.

    The message is here.

    Argument 1 passed to Orm\Query::_parse_where_array() must be an array, object given,
    called in /path/to/fuel/packages/orm/classes/query.php on line 529 and defined

  • HarroHarro
    Accepted Answer
    As I expected, you can not use DB::expr() in 1.5.
  • Thank you. I look for the another way.
  • Upgrade to 1.7.1 (or even 1.8/develop) would be the logical fix for this?

Howdy, Stranger!

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

In this Discussion