php - How to get the raw sql of doctrine -


i understand doctrine more , want analyse sql wich doctrine builds out of dql or find method.

is possible print statement out in php?

another question is: more performant, write own dqls joins or doctrine smart enough match these when use find method?

according logging doctrine sql queries in symfony2:

you can use doctrine logger such debugstack or own implementation of sqllogger interface.

$logger = new \doctrine\dbal\logging\debugstack();  /* @var doctrine\dbal\connection $connection */ $connection->getconfiguration()->setsqllogger($logger); 

after execution of queries can query strings , parameters public property of logger.

var_dump($logger->queries); 

you second question different. btw, said in documentation:

objects not loaded database replaced lazy load proxy instances. non-loaded collections replaced lazy-load instances fetch contained objects upon first access. relying on lazy-load mechanism leads many small queries executed against database, can affect performance of application. fetch joins solution hydrate or of entities need in single select query.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -