本文介绍了教义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'不等于'
发布评论