[limb-svn] r7011 - in 3.x/trunk/limb/dbal: src/drivers/mysqli src/toolkit tests/cases/toolkit

svn at limb-project.com svn at limb-project.com
Tue May 13 11:10:10 MSD 2008


Author: serega
Date: 2008-05-13 11:10:10 +0400 (Tue, 13 May 2008)
New Revision: 7011
URL: http://fisheye.limb-project.com/changelog/limb/?cs=7011

Modified:
   3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliConnection.class.php
   3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php
   3.x/trunk/limb/dbal/tests/cases/toolkit/lmbDbToolsTest.class.php
Log:
-- now db connection are stored in lmbDbTools only by dsn. Connection names are converted into dsns if someone wants to get or set db connection by name.

Modified: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliConnection.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliConnection.class.php	2008-05-13 06:26:02 UTC (rev 7010)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliConnection.class.php	2008-05-13 07:10:10 UTC (rev 7011)
@@ -55,8 +55,8 @@
   function connect()
   {
     $this->connectionId = mysqli_connect($this->config['host'],
-                                        $this->config['user'],
-                                        $this->config['password']);
+                                         $this->config['user'],
+                                         $this->config['password']);
 
     if($this->connectionId === false)
     {

Modified: 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php	2008-05-13 06:26:02 UTC (rev 7010)
+++ 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php	2008-05-13 07:10:10 UTC (rev 7011)
@@ -146,19 +146,18 @@
   
   function setDbConnectionByName($name, $conn)
   {
-    $this->dsnes_active[$name] = $conn;
+    if(!is_object($dsn = $this->toolkit->getDbDSNByName($name)))
+      throw new lmbException($name . ' database DSN is not valid');
+    
+    return $this->setDbConnectionByDsn($dsn, $conn);
   }
 
   function getDbConnectionByName($name)
   {
-    if(isset($this->dsnes_active[$name]) && is_object($this->dsnes_active[$name]))
-      return $this->dsnes_active[$name];
-
     if(!is_object($dsn = $this->toolkit->getDbDSNByName($name)))
       throw new lmbException($name . ' database DSN is not valid');
-
-    $this->setDbConnectionByName($name, $this->createDbConnection($dsn));
-    return $this->dsnes_active[$name];
+    
+    return $this->getDbConnectionByDsn($dsn);
   }
 
   function setDefaultDbConnection($conn)

Modified: 3.x/trunk/limb/dbal/tests/cases/toolkit/lmbDbToolsTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/toolkit/lmbDbToolsTest.class.php	2008-05-13 06:26:02 UTC (rev 7010)
+++ 3.x/trunk/limb/dbal/tests/cases/toolkit/lmbDbToolsTest.class.php	2008-05-13 07:10:10 UTC (rev 7011)
@@ -29,7 +29,7 @@
       'dsn' => 'mysql://root:test@localhost/hello_from_foo?charset=cp1251',
       'another_dsn' => 'sqlite://kraynopp:pasha@ksu/kadrs?charset=utf8'
     );
-    lmbToolkit::instance()->setConf('db', new lmbSet($this->config));
+    lmbToolkit :: instance()->setConf('db', new lmbSet($this->config));
     $this->tools->setDefaultDbConnection($this->tools->createDbConnection(new lmbDbDSN($this->config['dsn'])));
   }
   
@@ -113,4 +113,12 @@
 
     $this->assertIdentical($another_connection, $this->tools->getDbConnectionByDsn($dsn));
   }  
+  
+  function testGettingConnectionsByNameAndDSNReturnsTheSameConnectionObject()
+  {
+    $connection_by_name = $this->tools->getDbConnectionByName('another_dsn');
+    $connection_by_dsn = $this->tools->getDbConnectionByDsn($this->config['another_dsn']);
+    $this->assertReference($connection_by_name, $connection_by_dsn);
+  }
+  
 }



More information about the limb-svn mailing list