Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
DB Class error ? ('IN' and 'NOT IN')
  • Hi

    I discovered this while using ORM. But I suspect it is also present at the DB class.

    This expression:

    ->where('id', 'IN', '(1,2)')

    returns

    WHERE id IN '(1,2)'

    which returns an SQL error. It should be:

    WHERE id IN (1,2)

    Is this a bug? Or I'm must missing something?
  • HarroHarro
    Accepted Answer
    No, it's a feature. :-)

    Whenever you pass a string literal where a variable is expected, you have to encapsulate it using DB::expr(); Like so:

    ->where('id', 'IN', DB::expr('(1,2)'))

    You can also just pass an array

    ->where('id', 'IN', array(1,2))

Howdy, Stranger!

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

In this Discussion