public function testQueryEndLast() { $this->_profiler->queryStart('SELECT * FROM table'); $endResult = $this->_profiler->queryEndLast(); $this->assertAttributeEquals(null, '_lastQueryId', $this->_profiler); $this->assertEquals(Varien_Db_Profiler::STORED, $endResult); $endResult = $this->_profiler->queryEndLast(); $this->assertEquals(Varien_Db_Profiler::IGNORED, $endResult); }
/** * Starts a query. Creates a new query profile object (Zend_Db_Profiler_Query) * * @param string $queryText SQL statement * @param integer $queryType OPTIONAL Type of query, one of the Zend_Db_Profiler::* constants * @return integer|null */ public function queryStart($queryText, $queryType = null) { $result = parent::queryStart($queryText, $queryType); if ($result !== null) { $queryTypeParsed = $this->_parseQueryType($queryText); $timerName = $this->_getTimerName($queryTypeParsed); $tags = array(); // connection type to database $typePrefix = ''; if ($this->_type) { $tags['group'] = $this->_type; $typePrefix = $this->_type . ':'; } // sql operation $tags['operation'] = $typePrefix . $queryTypeParsed; // database host if ($this->_host) { $tags['host'] = $this->_host; } Magento_Profiler::start($timerName, $tags); } return $result; }