我有表名爲post
和列string
名爲status
與數據published
或pending
。現在我想用EntityRepository
類自定義方法從該表中提取所有行,或者只是修改現有的方法。如何查找所有查詢在Symfony 3 Doctrine
我已經試過這樣:
public function queryLatestPublished()
{
return $this->getEntityManager()
->createQuery('
SELECT p
FROM AppBundle:Post
WHERE p.staus == :st
ORDER BY p.created DESC
')
->setParameter('now', new \DateTime())
->setParameter('st', 'published')
;
}
但查詢不返回任何東西。
什麼是你試試這個問題(除非你有更多的參數設置比在查詢中使用)? – kero
它是symfony2還是symfony3?您的標題和標籤不匹配。 – k0pernikus
該代碼返回'Query'對象。您是否嘗試執行查詢?同樣在SQL和DQL中,相等運算符是'='not'=='。 – Crozin