문제

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 ?

도움이 되었습니까?

해결책

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();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top