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.
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.
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.