SilverStripe db选择多个键匹配

How can you select rows from a db table based on multiple "identifiers"?

Single key match

$id = 42;
DataObject::get('Foo')->where("ID = '$id'");

Multiple keys match

$id = array(42, 43, 44);
DataObject::get('Foo')->where( ??? );

In the second case it should return a list of rows that have an ID 42, 43 or 44.

SilverStripe ORM knows how to build where in queries:

$ids = array(42, 43, 44);
$items = Foo::get()->byIDs($ids);

For any other sets you should use DataList::filter() method;

$products = Product::get()->filter('Category', array('shirts', 'shoes'));

This seems to work:

$id = implode(',', array(42, 43, 44));

$items = DataObject::get('Foo')->where("ID IN ($id)");