/** * Insert a record in the queries table * * @param Doctrine_Event $event the event to log * * @throws Zend_Db_Profiler_Exception * * @return void */ public function recordEvent($event) { $this->message->setDestroy(false); // update time counter $this->totalElapsedTime += $event->getElapsedSecs(); // add a row to the table $this->message->addRow(array((string) round($event->getElapsedSecs(), 5), $event->getQuery() ? $event->getQuery() : $event->getName(), ($params = $event->getParams()) ? $params : null)); // increment number of queries $this->totalNumQueries++; }
/** * Intercept the query end and log the profiling data. * * @param integer $queryId * @throws Zend_Db_Profiler_Exception * @return void */ public function queryEnd($queryId) { $state = parent::queryEnd($queryId); if (!$this->getEnabled() || $state == self::IGNORED) { return; } $this->_message->setDestroy(false); $profile = $this->getQueryProfile($queryId); $this->_totalElapsedTime += $profile->getElapsedSecs(); $this->_message->addRow(array((string) round($profile->getElapsedSecs(), 5), $profile->getQuery(), ($params = $profile->getQueryParams()) ? $params : null)); $this->updateMessageLabel(); }
/** * method overloader * this method is used for invoking different listeners, for the full * list of availible listeners, see Doctrine_EventListener * * @param string $m the name of the method * @param array $a method arguments * @see Doctrine_EventListener * @return boolean */ public function __call($methodName, $arguments) { if (!$arguments[0] instanceof Doctrine_Event) { throw new Doctrine_Connection_Profiler_Exception("Couldn't listen event. Event should be an instance of Doctrine_Event."); } if (substr($methodName, 0, 3) == 'pre') { $arguments[0]->start(); if (!in_array($arguments[0], $this->_events, true)) { $this->_events[] = $arguments[0]; } } else { // we need after-event listeners $arguments[0]->end(); $this->_message->setDestroy(false); $this->_totalElapsedTime += $arguments[0]->getElapsedSecs(); $row = array($arguments[0]->getName(), round($arguments[0]->getElapsedSecs(), 5), $arguments[0]->getQuery(), ($params = $arguments[0]->getParams()) ? $params : null); $this->_message->addRow($row); $this->updateMessageLabel(); } }