Codeigniter Profiling Doctrine 2.0

What is a good way to profile doctrine requests when Doctrine 2.0 is integrated into codeigniter?

Using the regular CI profiler does not allow you to execute requests, because it uses Doctrine, and not its own active record.

eg. when adding this code $ this-> output-> enable_profiler (TRUE); It should also show completed requests.

http://codeigniter.com/user_guide/general/profiling.html

+4
source share
2 answers

You can add a profiler to the doctrine package

namespace Doctrine\DBAL\Logging; class Profiler implements SQLLogger { public $start = null; private $ci; public function __construct() { $this->ci =& get_instance(); } /** * {@inheritdoc} */ public function startQuery($sql, array $params = null, array $types = null) { $this->start = microtime(true); $this->ci->db->queries[] = "/* doctrine */ \n".$sql; } /** * {@inheritdoc} */ public function stopQuery() { $this->ci->db->query_times[] = microtime(true) - $this->start; } } 

Then load the profiler as a registrar in your main doctrine library (doctrine.php for me)

 $logger = new \Doctrine\DBAL\Logging\Profiler; $config->setSQLLogger($logger); 

And normal profiling will work fine.

+4
source

Source: https://habr.com/ru/post/1387500/


All Articles