I'm using Symfony 1.4 with Doctrine. I have a doctrine class called Image and a method that (should) find the next and previous values vi开发者_JAVA技巧a a query. The offending code looks like this:
$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());
I always get the
500 | Internal Server Error | Doctrine_Exception Couldn't find class a
error. Any hints?
Well, it turns out Doctrine is case sensitive in cases like this. The working code looks like this:
$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());
精彩评论