⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Retrieving from database with multiple id's



iblux
  • profile picture
  • Member

Posted 23 May 2012 - 13:43 PM

Hi everyone, I want to use grocery crud to retrieve groups from a database, using their id's, with a query like this:


SELECT * FROM Groups WHERE GroupID IN (3,8,12,23) //etc.



It's quite easy to do when you have a single id with
$crud->where
, but how should I tackle this one with multiple id's?

(btw, thank you web-johnny, for creating such an amazingly simple, and yet extensive crud, keep up the good work! :))

iblux
  • profile picture
  • Member

Posted 24 May 2012 - 08:55 AM

Nobody?

kenvogt
  • profile picture
  • Member

Posted 24 May 2012 - 18:33 PM

Try or_where

iblux
  • profile picture
  • Member

Posted 25 May 2012 - 10:31 AM

Thanks! I used a foreach loop:


foreach($data['ids'] as $id)
{
$crud->or_where('grpId', $id);
}

mavershim
  • profile picture
  • Member

Posted 01 October 2012 - 08:47 AM

or you can try
$crud->where("GroupID in (1,2,3,5)");