Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattpiwik <matthieu.aubry@gmail.com>2008-05-23 05:08:12 +0400
committermattpiwik <matthieu.aubry@gmail.com>2008-05-23 05:08:12 +0400
commit3ee758618315c185aae84bbd71ca358b0c6023dd (patch)
treef37de2de376090fc4f44b524c7a5fba17b10e256 /modules/LogStats.php
parentbf196060692597ca9658758d68109afd4382c672 (diff)
- fixing notice in Log message
- db object is now static in LogStats, boosting performance of the visits generator tool git-svn-id: http://dev.piwik.org/svn/trunk@492 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'modules/LogStats.php')
-rw-r--r--modules/LogStats.php37
1 files changed, 21 insertions, 16 deletions
diff --git a/modules/LogStats.php b/modules/LogStats.php
index b16b9d6b07..c121fea3ef 100644
--- a/modules/LogStats.php
+++ b/modules/LogStats.php
@@ -54,7 +54,7 @@ class Piwik_LogStats
*
* @var Piwik_LogStats_Db
*/
- protected $db = null;
+ static protected $db = null;
const STATE_NOTHING_TO_NOTICE = 1;
const STATE_TO_REDIRECT_URL = 2;
@@ -75,22 +75,35 @@ class Piwik_LogStats
}
// create the database object
- function connectDatabase()
+ static function connectDatabase()
{
+ if( !is_null(self::$db))
+ {
+ return;
+ }
+
$configDb = Piwik_LogStats_Config::getInstance()->database;
// we decode the password. Password is html encoded because it's enclosed between " double quotes
$configDb['password'] = htmlspecialchars_decode($configDb['password']);
- $this->db = new Piwik_LogStats_Db( $configDb['host'],
+ self::$db = new Piwik_LogStats_Db( $configDb['host'],
$configDb['username'],
$configDb['password'],
$configDb['dbname']
);
- $this->db->connect();
+ self::$db->connect();
}
+ static function disconnectDb()
+ {
+ if(isset(self::$db))
+ {
+ self::$db->disconnect();
+ }
+ }
+
private function initProcess()
{
try{
@@ -172,7 +185,7 @@ class Piwik_LogStats
*/
protected function getNewVisitObject()
{
- return new Piwik_LogStats_Visit($this->db);
+ return new Piwik_LogStats_Visit(self::$db);
}
// main algorithm
@@ -185,7 +198,7 @@ class Piwik_LogStats
if( $this->processVisit() )
{
try {
- $this->connectDatabase();
+ self::connectDatabase();
$visit = $this->getNewVisitObject();
$visit->handle();
} catch (PDOException $e) {
@@ -229,18 +242,10 @@ class Piwik_LogStats
if($GLOBALS['DEBUGPIWIK'] === true)
{
- Piwik::printSqlProfilingReportLogStats($this->db);
+ Piwik::printSqlProfilingReportLogStats(self::$db);
}
- $this->disconnectDb();
- }
-
- protected function disconnectDb()
- {
- if(isset($this->db))
- {
- $this->db->disconnect();
- }
+ self::disconnectDb();
}
protected function outputTransparentGif()