How to implement \Phalcon\Mvc\Model::findIn()?

大兔子大兔子 提交于 2020-01-30 12:15:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!