Check out the Phalcon\Mvc\Model\Criteria, in the inWhere
method.
You could create a new model's method like:
public static function findIn(array $identifiers)
{
return self::query()
->inWhere('id', $identifiers)
->execute();
}
Question
Fairly simple question, but I can't seem to find anything about it.
I've got a set of ids, and I need to find all matching records.
So I'd like to query :
$records = MyModel::findIn([1,2,3,4]);
But I don't know how to implement it. Any idea ?
Solution
Check out the Phalcon\Mvc\Model\Criteria, in the inWhere
method.
You could create a new model's method like:
public static function findIn(array $identifiers)
{
return self::query()
->inWhere('id', $identifiers)
->execute();
}