当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Db_Profiler类代码示例

本文整理汇总了PHP中Zend_Db_Profiler的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Profiler类的具体用法?PHP Zend_Db_Profiler怎么用?PHP Zend_Db_Profiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Db_Profiler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _initProfiler

 protected function _initProfiler()
 {
     $this->bootstrap('db');
     $profiler = new Zend_Db_Profiler('All DB Queries');
     $profiler->setEnabled(true);
     $this->getResource('db')->setProfiler($profiler);
 }
开发者ID:Roave,项目名称:issues,代码行数:7,代码来源:Bootstrap.php

示例2: _getProfilerMarkup

 private function _getProfilerMarkup(Zend_Db_Profiler $profiler)
 {
     $totalTime = $profiler->getTotalElapsedSecs();
     $queryCount = $profiler->getTotalNumQueries();
     $longestTime = 0;
     $longestQuery = null;
     $lines = array();
     $html = "<h2>Db Profiler</h2>\n";
     $lines[] = "The following queries were executed during the request:";
     $profiles = $profiler->getQueryProfiles();
     if (!$profiles) {
         return $html;
     }
     foreach ($profiles as $query) {
         $sql = $query->getQuery();
         $elapsedSecs = $query->getElapsedSecs();
         if ($elapsedSecs > $longestTime) {
             $longestTime = $query->getElapsedSecs();
             $longestQuery = $sql;
         }
         $lines[] = "[{$elapsedSecs}] {$sql}";
     }
     $lines[] = 'Executed ' . $queryCount . ' queries in ' . $totalTime . ' seconds';
     $lines[] = 'Average query length: ' . $totalTime / $queryCount . ' seconds';
     $lines[] = 'Queries per second: ' . $queryCount / $totalTime;
     $lines[] = 'Longest query length: ' . $longestTime;
     $lines[] = "Longest query: \n" . $longestQuery;
     foreach ($lines as $line) {
         $html .= '<p>' . $line . '</p>' . "\n";
     }
     return $html;
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:32,代码来源:Debug.php

示例3: rollBack

 /**
  * Roll back a transaction and return to autocommit mode.
  *
  * @return Zend_Db_Adapter_Abstract
  */
 public function rollBack()
 {
     $this->_connect();
     $q = $this->_profiler->queryStart('rollback', Zend_Db_Profiler::TRANSACTION);
     $this->_rollBack();
     $this->_profiler->queryEnd($q);
     return $this;
 }
开发者ID:Gradven,项目名称:what3.1.7,代码行数:13,代码来源:Abstract.php

示例4: queryEnd

 /**
  * 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;
     }
     $profile = $this->getQueryProfile($queryId);
     echo (string) round($profile->getElapsedSecs(), 5) . PHP_EOL . $profile->getQuery() . PHP_EOL . (($params = $profile->getQueryParams()) ? $params : null) . PHP_EOL;
 }
开发者ID:null-1,项目名称:fangtaitong,代码行数:16,代码来源:Console.php

示例5: queryEnd

 /**
  * 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;
     }
     $profile = $this->getQueryProfile($queryId);
     $this->_totalElapsedTime += $profile->getElapsedSecs();
     $this->_totalQueries++;
     $logEntry = $profile->getQuery() . " | " . implode(",", $profile->getQueryParams());
     \Logger::debug($logEntry, ["connection" => $this->getConnectionId(), "queryNum" => $this->_totalQueries, "time" => (string) round($profile->getElapsedSecs(), 5)]);
     $this->queries[] = array("time" => $profile->getElapsedSecs(), "query" => $profile->getQuery() . " | " . implode(",", $profile->getQueryParams()));
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:20,代码来源:Profiler.php

示例6: queryEnd

 /**
  * 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;
     }
     // get profile of the current query
     $profile = $this->getQueryProfile($queryId);
     // update totalElapsedTime counter
     $this->_totalElapsedTime += $profile->getElapsedSecs();
     // create the message to be logged
     $message = "\nElapsed Secs: " . round($profile->getElapsedSecs(), 5) . "\n";
     $message .= "Query: " . $profile->getQuery() . "\n";
     // log the message as INFO message
     $this->_log->info($message);
 }
开发者ID:MichaelGogeshvili,项目名称:sitewatch,代码行数:23,代码来源:Log.php

示例7: queryEnd

 public function queryEnd($queryId)
 {
     $result = parent::queryEnd($queryId);
     if ($result == self::STORED) {
         $profile = $this->getLastQueryProfile();
         /* @var $profile Zend_Db_Profiler_Query */
         if (!isset($this->_types[$profile->getQueryType()])) {
             $this->_types[$profile->getQueryType()] = 0;
         }
         $this->_types[$profile->getQueryType()]++;
         $query = $profile->getQuery();
         $data = array('query' => $query, 'elapsed' => $profile->getElapsedSecs(), 'params' => $profile->getQueryParams());
         $data = json_encode($data);
         $queue = Mage::getStoreConfig(Eschrade_PubSubLogger_Model_Observer::SYSTEM_CONFIG_ENDPOINT) . '_pslogger_sql';
         $this->_observer->publish($queue, $data);
     }
 }
开发者ID:brianhillz0r,项目名称:Magento-Realtime-Logger,代码行数:17,代码来源:Profiler.php

示例8: queryEnd

 /**
  * 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;
     }
     $profile = $this->getQueryProfile($queryId);
     $this->_totalElapsedTime += $profile->getElapsedSecs();
     $logEntry = "DB Query: " . (string) round($profile->getElapsedSecs(), 5) . " | " . $profile->getQuery() . " | " . implode(",", $profile->getQueryParams());
     Logger::debug($logEntry);
     if (!empty($_REQUEST["pimcore_dbprofile"])) {
         if (!is_resource($this->logFile)) {
             $logFile = dirname(PIMCORE_LOG_DEBUG) . "/dbprofile-" . $_REQUEST["pimcore_dbprofile"] . ".log";
             file_put_contents($logFile, "");
             $this->logFile = fopen($logFile, "a+");
         }
         fwrite($this->logFile, $logEntry . "\n");
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:26,代码来源:Profiler.php

示例9: _initDbProfiler

 protected function _initDbProfiler()
 {
     if (APPLICATION_ENV === 'development') {
         if (isset($_GET['_profileSql'])) {
             setcookie('_profileSql', $_GET['_profileSql']);
         }
         if (isset($_COOKIE['_profileSql'])) {
             $profiler = new Zend_Db_Profiler();
             $profiler->setEnabled(true);
             Zend_Db_Table_Abstract::getDefaultAdapter()->setProfiler($profiler);
             register_shutdown_function(array('Tools_System_Tools', 'sqlProfiler'));
         }
     }
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:14,代码来源:Bootstrap.php

示例10: profiler

/**
 * Get DB profiler
 *
 * @param string $connectionName
 * @return mixed|Zend_Db_Profiler
 */
function profiler($connectionName = 'core_read')
{
    if (false == ($profiler = Mage::registry('profiler'))) {
        /** @var $resource Mage_Core_Model_Resource */
        $resource = Mage::getSingleton('core/resource');
        /** @var $db Varien_Db_Adapter_Pdo_Mysql */
        $db = $resource->getConnection($connectionName);
        $profiler = new Zend_Db_Profiler();
        $profiler->setEnabled(1);
        $db->setProfiler($profiler);
        Mage::register('profiler', $profiler);
    }
    return $profiler;
}
开发者ID:virtual97,项目名称:quick-debug,代码行数:20,代码来源:func.php

示例11: queryStart

 /**
  * Starts a query.  Creates a new query profile object (Zend_Db_Profiler_Query)
  * and returns the "query profiler handle".  Run the query, then call
  * queryEnd() and pass it this handle to make the query as ended and
  * record the time.  If the profiler is not enabled, this takes no
  * action and immediately returns null.
  *
  * @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)
 {
     //        file_put_contents('/var/www/query.log',$queryText."\n\n",FILE_APPEND);
     return parent::queryStart($queryText, $queryType);
 }
开发者ID:hashir-dhattiwala,项目名称:vfmagento,代码行数:16,代码来源:VafdefinitionsimporterController.php

示例12: queryEnd

 /**
  * 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();
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:19,代码来源:Firebug.php

示例13: getQueries

 /**
  * Returns all the db queries made
  *
  * @return array
  */
 public function getQueries()
 {
     if ($this->_profiler->getQueryProfiles() != null) {
         return $this->_profiler->getQueryProfiles();
     }
     return array();
 }
开发者ID:nicolas-bastien,项目名称:MagentoUnderControl,代码行数:12,代码来源:Database.php

示例14: assertTotalNumQueries

 /**
  * Assert that the given number of SQL queries were made.
  * 
  * @param integer $queryCount
  */
 public function assertTotalNumQueries($queryCount, $msg = null)
 {
     if (!$msg) {
         $msg = "Failed asserting that " . (int) $queryCount . " SQL queries were made.";
     }
     $this->_test->assertEquals($queryCount, $this->_profiler->getTotalNumQueries(), $msg);
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:12,代码来源:DbProfiler.php

示例15: getAllQuerys

 private function getAllQuerys()
 {
     foreach ($this->doctrineProfiler->queries as $query) {
         $this->executedQuerys[] = ['sql' => $query['sql'], 'params' => $query['params'], 'execution' => $query['executionMS']];
         $this->executeTime += $query['executionMS'];
     }
     foreach ($this->zendProfiler->getQueryProfiles() as $queryProfile) {
         $this->executedQuerys[] = ['sql' => $queryProfile->getQuery(), 'params' => $queryProfile->getQueryParams(), 'execution' => $queryProfile->getElapsedSecs()];
     }
 }
开发者ID:shyim,项目名称:shopware-profiler,代码行数:10,代码来源:DBCollector.php


注:本文中的Zend_Db_Profiler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。