Reputation: 15
I'm tying to do the following mysql with Kohana ORM:
SELECT column_id FROM tables WHERE column_id IN (2, 3, 6)
How do I do this?
Upvotes: 1
Views: 719
Reputation: 15
Ended up using:
->and_where('column_id', 'in', $args())
Decided to stick with ORM db methods instead of kohana's database query builders.
Upvotes: 0
Reputation: 10371
If tables
is the name of your table, try something like
$rows = ORM::factory('tables')->in('column_id', array(2, 3, 6))->find_all();
Since in()
is failing for you through the ORM, this should work in the interim:
$rows = DB::select()->from('tables')->where('column_id', 'IN', array(2, 3, 6));
Upvotes: 1
Reputation: 2265
You can use the following syntax in kohana ORM:
in()
Creates an IN portion of a query.
It has three parameters:
1.the column to match
2.an array or string of values to match against (boolean),
3. to create a NOT clause instead
$db->in('title', array(1,2,3,4,5));
This generates: title IN ('1','2','3','4','5')
Upvotes: 2