简体   繁体   English

Phalcon-将OR条件添加到find()

[英]Phalcon - add OR criteria to find()

hope someone can help. 希望有人可以帮忙。

I am using the find() as follows 我正在使用find()如下

$query = Criteria::fromInput($this->di, 'Models\Templates', $this->request->getPost());
$this->persistent->searchParams = $query->getParams();
$parameters = $this->persistent->searchParams;
$templates= templates::find(
        $parameters,
        );

This gives me the resulting set of templates based on the parameters posted. 这使我根据发布的参数生成了一组模板。

What I want to be able to do is add to these parameters an OR somehow. 我想要做的就是以某种方式将OR添加到这些参数中。

ie find all the templates which have the criteria as per the post, OR ones which have the field "global" set to Y 例如,找到所有符合条件的模板,或者找到“ global”字段设置为Y的模板

I was going to run a second query to get the global templates and concatenate the results set, but surely there must be some way to add an OR to the criteria? 我打算运行第二个查询以获取全局模板并连接结果集,但是肯定有某种方法可以将OR添加到条件中?

Any help would be really gratefully received! 任何帮助将非常感激!

Martin 马丁

$query = Criteria::fromInput($this->di, 'Models\Templates', $this->request->getPost());

//added this below to add the additional or query to the Criteria builder

$query->orWhere("global = 'Y'");

$this->persistent->searchParams = $query->getParams();
parameters = $this->persistent->searchParams;
$templates= templates::find(
    $parameters,
    );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM