[limb-svn] r5996 - 3.x/trunk/limb/dbal/src/toolkit

svn at limb-project.com svn at limb-project.com
Mon Jun 18 16:20:00 MSD 2007


Author: pachanga
Date: 2007-06-18 16:20:00 +0400 (Mon, 18 Jun 2007)
New Revision: 5996
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5996

Modified:
   3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php
Log:
-- lmbDbTools :: createTableGateway(..) now accept second optional db connection object argument 

Modified: 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php	2007-06-15 10:55:31 UTC (rev 5995)
+++ 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php	2007-06-18 12:20:00 UTC (rev 5996)
@@ -1,22 +1,22 @@
 <?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com 
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/toolkit/src/lmbAbstractTools.class.php');
 lmb_require('limb/dbal/src/lmbDBAL.class.php');
 lmb_require('limb/dbal/src/lmbDbDSN.class.php');
-lmb_require('limb/dbal/src/drivers/lmbDbCachedInfo.class.php');
-
+lmb_require('limb/dbal/src/drivers/lmbDbCachedInfo.class.php');
+
 /**
  * class lmbDbTools.
  *
  * @package dbal
  * @version $Id$
- */
+ */
 class lmbDbTools extends lmbAbstractTools
 {
   protected $default_connection;
@@ -131,13 +131,18 @@
     $this->default_connection = $conn;
   }
 
-  function createTableGateway($table_name)
+  function createTableGateway($table_name, $conn = null)
   {
-    if(isset($this->db_tables[$table_name]))
-      return $this->db_tables[$table_name];
+    if(!$conn)
+      $cache_key = $table_name;
+    else
+      $cache_key = $table_name . $conn->getHash();
 
-    $db_table = new lmbTableGateway($table_name);
-    $this->db_tables[$table_name] = $db_table;
+    if(isset($this->db_tables[$cache_key]))
+      return $this->db_tables[$cache_key];
+
+    $db_table = new lmbTableGateway($table_name, $conn);
+    $this->db_tables[$cache_key] = $db_table;
     return $db_table;
   }
 }



More information about the limb-svn mailing list