问题
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 ?
回答1:
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();
}
来源:https://stackoverflow.com/questions/23368383/how-to-implement-phalcon-mvc-modelfindin