Ejemplo n.º 1
0
	/**
	 * When destroyed, if SQL profiled enabled, logs the SQL profiling information
	 */
	public function recordProfiling()
	{
		if(is_null($this->connection)) 
		{
			return;
		}
	
		// turn off the profiler so we don't profile the following queries 
		self::$profiling = false;
		
		foreach($this->queriesProfiling as $query => $info)
		{
			$time = $info['sum_time_ms'];
			$count = $info['count'];

			$queryProfiling = "INSERT INTO ".Piwik_Common::prefixTable('log_profiling')."
						(query,count,sum_time_ms) VALUES (?,$count,$time)
						ON DUPLICATE KEY 
							UPDATE count=count+$count,sum_time_ms=sum_time_ms+$time";
			$this->query($queryProfiling,array($query));
		}
		
		// turn back on profiling
		self::$profiling = true;
	}
Ejemplo n.º 2
0
 /**
  * When destroyed, if SQL profiled enabled, logs the SQL profiling information
  */
 public function recordProfiling()
 {
     if (is_null($this->connection)) {
         return;
     }
     // turn off the profiler so we don't profile the following queries
     self::$profiling = false;
     foreach ($this->queriesProfiling as $query => $info) {
         $time = round($info['sum_time_ms']);
         $count = $info['count'];
         try {
             $queryProfiling = "UPDATE " . Piwik_Common::prefixTable('log_profiling') . "\n\t\t\t\t\t\tSET count=count+?, sum_time_ms=sum_time_ms+?\n\t\t\t\t\t\tWHERE query=?";
             $this->query($queryProfiling, array($count, $time, $query));
         } catch (Exception $e) {
             $queryProfiling = "INSERT INTO " . Piwik_Common::prefixTable('log_profiling') . "\n\t\t\t\t\t\t\t(count,sum_time_ms,query) VALUES (?,?,?)";
             $this->query($queryProfiling, array($count, $time, $query));
         }
     }
     // turn back on profiling
     self::$profiling = true;
 }