1

I am new to Doctrine and trying to run DQL statements with the Doctrine CLI tool for convenience in debugging. My configuration appears to be set up correctly in cli-config.php. I can run things like vendor/bin/doctrine orm:info and generate setters and getters. In my Zend Framework 2 web application I can get my entity repository from the service manager, manipulate entities, run some DQL through createQuery(), and so on. So this works in a controller action:

$query = $em->createQuery('SELECT j FROM Application\Entity\Judge j');
$judges = $query->getResult();
printf("we got %d judges in our table",count($judges));

But when I try, for example, to

vendor/bin/doctrine orm:run-dql 'SELECT j FROM Application\Entity\Judge j'

I get:

[Doctrine\ORM\Query\QueryException]
[Semantical Error] line 0, col 14 near 'Application\Entity\Judge': Error: Class 'Application\Entity\Judge' is not defined.

And I have tried this with a number of entity classes. Any thoughts?

Thanks.

David
  • 815
  • 8
  • 18
  • 1
    Did you ever figure this out? – Alec Mar 15 '16 at 17:13
  • @alec um, yes, I am embarrassed to say that I did but I don't know how, because I moved on and then came back to it some months later and it worked. Something must have been misconfigured, class loading not happening... It may have an element/path missing from the $entitiesPath array in my bootstrap.php. – David Mar 16 '16 at 16:06
  • Yeah, I ended up having to go with a NativeQuery instead. :/ – Alec Mar 17 '16 at 13:02
  • sorry I couldn't be more helpful. maybe if you ignore it for a few months, it will heal itself -- that worked for me (-: ...wait, are you saying you get this not only from the CLI but also in a web browser (or whatever environment you're ultimately aiming for)? that's kind of a show-stopper and you should not have to fall back on NativeQuery except in rare cases. have posted a full-blown Question? – David Mar 18 '16 at 19:30

0 Answers0