Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
DB Class error ? ('IN' and 'NOT IN')
arnoldgamboa
February 2013
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?
Harro
February 2013
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))
arnoldgamboa
February 2013
Thanks, man.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
arnoldgamboa
February 2013
Harro
February 2013