Matt
Matt

Reputation: 1072

"Couldn't find class" Doctrine Subqueries

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 via 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?

Upvotes: 2

Views: 4176

Answers (1)

Matt
Matt

Reputation: 1072

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());

Upvotes: 3

Related Questions