教义findBy'不等于'

编程入门 行业动态 更新时间:2024-10-23 09:38:44
本文介绍了教义findBy'不等于'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何执行

WHERE id != 1

在Doctrine?

我有这么远

$this->getDoctrine()->getRepository('MyBundle:Image')->findById(1);

但是我该怎么做不等于?

But how do I do a "do not equals"?

这可能是愚蠢的,但是我找不到任何这个引用?

This maybe daft, but I cannot find any reference to this?

谢谢

推荐答案

没有内置的方法允许您打算做什么。

There is no built-in method that allows what you intend to do.

您必须向存储库添加一个方法,像这样:

You have to add a method to your repository, like this:

public function getWhatYouWant() { $qb = $this->createQueryBuilder('u'); $qb->where('u.id != :identifier') ->setParameter('identifier', 1); return $qb->getQuery() ->getResult(); }

希望这有帮助。

更多推荐

教义findBy'不等于'

本文发布于:2023-11-15 21:38:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598176.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:教义   不等于   findBy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!