如何使用 Symfony 在 Propel 查询中使用 OR 语句
现在,下面的代码在数据库中查找author_id和target_object_id,并要求两者匹配,以便通过查询检索。我希望它位于 WHEREauthor_id='x' || target_object_id='y'
而不是 &&默认情况下,这就是下面的代码的作用。
我看过 Propel 和 Symfony 手册,但它们对我没有帮助。
$c = new Criteria();
$c->add("type", GVCCommentPeer::TYPE_PRIVATE_MESSAGE);
$c->add("author_id", $this->myprofileid);
$c->add("target_object_id", $this->profile->getId());
Right now the code below looks for the author_id and the target_object_id in the database and requires both to match, to be retreived by the query. I would like it to be WHERE author_id='x' || target_object_id='y'
instead of it being && by default, which is what the code below does.
I've looked on Propel and the Symfony manuals, and they don't help me.
$c = new Criteria();
$c->add("type", GVCCommentPeer::TYPE_PRIVATE_MESSAGE);
$c->add("author_id", $this->myprofileid);
$c->add("target_object_id", $this->profile->getId());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从 Criteria 对象创建 Criterion 对象,并根据您需要的条件合并它们:
You need to create Criterion objects from your Criteria object and merge them on the condition you require: