[xiph-commits] r14856 - branches/dir.xiph.org/inc

balbinus at svn.xiph.org balbinus at svn.xiph.org
Sat May 10 11:46:54 PDT 2008


Author: balbinus
Date: 2008-05-10 11:46:54 -0700 (Sat, 10 May 2008)
New Revision: 14856

Modified:
   branches/dir.xiph.org/inc/inc.db.php
Log:
Made the two connection classes independent.

Modified: branches/dir.xiph.org/inc/inc.db.php
===================================================================
--- branches/dir.xiph.org/inc/inc.db.php	2008-05-10 18:37:12 UTC (rev 14855)
+++ branches/dir.xiph.org/inc/inc.db.php	2008-05-10 18:46:54 UTC (rev 14856)
@@ -94,8 +94,12 @@
 	}
 }
 
-class DirXiphOrgLogDBC extends DirXiphOrgDBC
+class DirXiphOrgLogDBC extends DatabaseConnection
 {
+    private static $instance;
+	public $queries = 0;
+	public $log = array();
+	
 	/**
 	* Constructor.
 	*/
@@ -103,6 +107,40 @@
 	{
 		parent::__construct(LOG_DB_HOST, LOG_DB_USER, LOG_DB_PASS, LOG_DB_NAME);
 	}
+	
+	public function query($sql)
+	{
+		$this->queries++;
+		$start = microtime(true);
+		
+		$res = parent::query($sql);
+		$nb = $this->affectedRows();
+		
+		$time = (microtime(true) - $start) * 1000;
+		$this->log[] = array('query'=>$sql,
+		                     'time'=>round($time, 3),
+		                     'rows'=>$nb);
+		
+		return $res;
+	}
+	
+	/**
+	 * Returns an instance of the DatabaseConnection.
+	 */
+	public static function getInstance($force_new = false, $auto_connect = true)
+	{ 
+		if (!isset(self::$instance) || $force_new)
+		{
+			self::$instance = new DirXiphOrgLogDBC();
+		}
+		
+		if ($auto_connect)
+		{
+		    self::$instance->connect();
+		}
+		
+		return self::$instance;
+	}
 }
 
 ?>



More information about the commits mailing list