我用Symfony 1.4来解释教义。我有一个名为Image的doctrine类和一个方法(应该)通过查询找到下一个和上一个值。违规代码如下所示:
$q = Doctrine_Core::getTable('Image')->createQuery()
->from('Image i')
->where('i.id = (select max(a.id) from Image a where ? > a.id and is_active = 1)', $this->getId())
->orWhere('i.id = (select min(b.id) from Image b where ? < b.id and is_active = 1)', $this->getId());
我总是得到
500 |内部服务器错误|条令|异常找不到a级
错误。有什么线索吗?
最佳答案
嗯,事实证明,在这种情况下,条令是区分大小写的。工作代码如下所示:
$q = Doctrine_Core::getTable('Image')->createQuery()
->from('Image i')
->where('i.id = (SELECT MAX(a.id) FROM Image a WHERE ? > a.id AND is_active = 1)', $this->getId())
->orWhere('i.id = (SELECT MIN(b.id) FROM Image b WHERE ? < b.id AND is_active = 1)', $this->getId());
关于php - “找不到类(class)” Doctrine 子查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4693796/