学说 findBy '不等于' [英] Doctrine findBy 'does not equal'
本文介绍了学说 findBy '不等于'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该怎么办
WHERE id != 1
在教义中?
到目前为止我有这个
$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 '不等于'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文