0

I have a bit of Doctrine ORM code like so:

$query = $this->entityManager->createQuery('SELECT c FROM specialty\models\entities\Clan c WHERE c.Id = ?1');

This code has worked without a problem for ages. I recently reinstalled my LAMP stack environment and my Netbeans IDE and merely checked out the code from SVN. Now, however, this bit of code throws up the following error:

exception 'Doctrine\ORM\Query\QueryException' with message '[Semantical Error] line 0, col 14 near 'specialty\modelsentities\Clan': Error: Class 'specialty\modelsentities\Clan' is not defined here.'

Looking at the error message, there is a missing '\' between 'models' and 'entities'. While this ought to be '\models\entities', it is 'seen' as '\modelsentities' - which definitely does not exist - hence the error.

For some weird reason, the slash is stripped off before the code is parsed, I think. Problem is, I have not been able to find the cause of this. I observed that the problem disappears when the WHEN clause is removed from the statement like so:

$query = $this->entityManager->createQuery('SELECT c FROM specialty\models\entities\Clan c');

I have tried escaping possibly invisible control characters, checking new environment settings in php.ini (for example) for clues as to what could be cause of the error. Please help, thanks.

hakre
  • 193,403
  • 52
  • 435
  • 836
pi.
  • 1,441
  • 3
  • 19
  • 25
  • What about using an interactive debugger to figure out where it's happening on the doctrine library? – Keyne Viana Mar 27 '12 at 22:48
  • how about declaring a namespace for your entities? (to try something at least), try adding `namespace specialty\modelsentities\Clan` on top of your `Clan` class declaration to see what happens – jere Mar 28 '12 at 14:13
  • @Keyne: I tried using xdebug but could not track it down. Not sure of the best way to use xDebug on an MVC application. Thanks – pi. Mar 28 '12 at 14:31
  • @jere: I did. the application progressed beyond that point but hit a wall again as other components requiring that entity failed to locate it. I created a duplicate file changing just the namespace but that didn't work either. please help! – pi. Mar 28 '12 at 14:37
  • @jere: I just re-read your comment. My Entities are namespaced classes already as you seem to be suggesting. Thanks – pi. Mar 28 '12 at 14:40

2 Answers2

0

Do you have auto proxy generation on? If so, try turning it off and manually regenerate the proxies.

If you have auto proxy generation off already, simply try regenerating the proxies and see if that helps.

Wil Moore III
  • 6,968
  • 3
  • 36
  • 49
  • I have tried that and it is still coming up with the same error message. It is crazy! – pi. Mar 29 '12 at 14:36
0

The problem was as a result of the fact that I had installed version 5.4 of PHP during my re-installation. According to the PHP web site, a new control/escape character was introduced in version 5.4

\e  escape (ESC or 0x1B (27) in ASCII) (since PHP 5.4.0)

Obviously, the createQuery() method in Doctrine 2.0's entitymanager class is not escaping this well when it encounters:

blah\models\entities\blah [contains the new escape character]

The previous version I had was version 5.3.10 which was without the newly introduced escape character.

Solution was to revert back to PHP 5.3. Not sure if upgrading to Doctrine 2.1 or later would solve the problem as well.

pi.
  • 1,441
  • 3
  • 19
  • 25