如何实现PhalconMvcModel::findIn()? [英] How to implement PhalconMvcModel::findIn()?

查看:11
本文介绍了如何实现PhalconMvcModel::findIn()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相当简单的问题,但我似乎找不到任何相关信息.

Fairly simple question, but I can't seem to find anything about it.

我有一组 id,我需要找到所有匹配的记录.

I've got a set of ids, and I need to find all matching records.

所以我想查询:

$records = MyModel::findIn([1,2,3,4]);

但是我不知道如何实现它.有什么想法吗?

But I don't know how to implement it. Any idea ?

推荐答案

查看 PhalconMvcModelCriteria,在 inWhere 方法中.

Check out the PhalconMvcModelCriteria, 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();
}

这篇关于如何实现PhalconMvcModel::findIn()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆