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

svn at limb-project.com svn at limb-project.com
Wed Jun 20 01:09:36 MSD 2007


Author: pachanga
Date: 2007-06-20 01:09:36 +0400 (Wed, 20 Jun 2007)
New Revision: 6002
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6002

Modified:
   3.x/trunk/limb/dbal/src/lmbDbDSN.class.php
Log:
-- only first character is stripped from 'path' attribute, this allows to pass proper db path for sqlite driver on *nix

Modified: 3.x/trunk/limb/dbal/src/lmbDbDSN.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/lmbDbDSN.class.php	2007-06-19 09:07:26 UTC (rev 6001)
+++ 3.x/trunk/limb/dbal/src/lmbDbDSN.class.php	2007-06-19 21:09:36 UTC (rev 6002)
@@ -1,96 +1,96 @@
-<?php
+<?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 
- */
-lmb_require('limb/net/src/lmbUri.class.php');
+ */
+lmb_require('limb/net/src/lmbUri.class.php');
 lmb_require('limb/core/src/lmbObject.class.php');
 
-/**
- * class lmbDbDSN.
- *
- * @package dbal
- * @version $Id$
+/**
+ * class lmbDbDSN.
+ *
+ * @package dbal
+ * @version $Id$
  */
-class lmbDbDSN extends lmbObject
-{
-  protected $uri;
-  protected $extra = array();
-
-  function __construct($args)
-  {
-    if(is_array($args))
-    {
-      foreach($args as $key => $value)
-      {
-        if(is_numeric($key) && is_array($value))
-          $this->extra = $value;
-        else
-          $this->$key = $value;
-      }
-    }
-    elseif(is_string($args))
-      $this->_parseUri($args);
-  }
-
-  function _parseUri($str)
-  {
-    try
-    {
-      $this->uri = new lmbUri($str);
-    }
-    catch(lmbException $e)
-    {
-      throw new lmbException("Database DSN '$str' is not valid");
-    }
-
-    $this->driver = $this->uri->getProtocol();
-    $this->host = $this->uri->getHost();
-    $this->user = $this->uri->getUser();
-    $this->password = $this->uri->getPassword();
-    $this->database = ltrim($this->uri->getPath(), '/');
-    $this->port = $this->uri->getPort();
-    $this->extra = $this->uri->getQueryItems();
-  }
-
-  function _getUri()
-  {
-    if(is_object($this->uri))
-      return $this->uri;
-
-    $this->uri = new lmbUri();
-    $this->uri->setProtocol($this->driver);
-    $this->uri->setHost($this->host);
-    $this->uri->setUser($this->user);
-    $this->uri->setPassword($this->password);
-    $this->uri->setPath('/' . $this->database);
-
-    if(isset($this->port))
-      $this->uri->setPort($this->port);
-    if(count($this->extra))
-      $this->uri->setQueryItems($this->extra);
-
-    return $this->uri;
-  }
-
-  function get($name)
-  {
-    $value = parent :: get($name);
-
-    if(isset($value))
-      return $value;
-
-    if(isset($this->extra[$name]))
-      return $this->extra[$name];
-  }
-
-  function toString()
-  {
-    return $this->_getUri()->toString();
-  }
-}
-
-?>
+class lmbDbDSN extends lmbObject
+{
+  protected $uri;
+  protected $extra = array();
+
+  function __construct($args)
+  {
+    if(is_array($args))
+    {
+      foreach($args as $key => $value)
+      {
+        if(is_numeric($key) && is_array($value))
+          $this->extra = $value;
+        else
+          $this->$key = $value;
+      }
+    }
+    elseif(is_string($args))
+      $this->_parseUri($args);
+  }
+
+  function _parseUri($str)
+  {
+    try
+    {
+      $this->uri = new lmbUri($str);
+    }
+    catch(lmbException $e)
+    {
+      throw new lmbException("Database DSN '$str' is not valid");
+    }
+
+    $this->driver = $this->uri->getProtocol();
+    $this->host = $this->uri->getHost();
+    $this->user = $this->uri->getUser();
+    $this->password = $this->uri->getPassword();
+    $this->database = substr($this->uri->getPath(), 1);//removing only first slash
+    $this->port = $this->uri->getPort();
+    $this->extra = $this->uri->getQueryItems();
+  }
+
+  function _getUri()
+  {
+    if(is_object($this->uri))
+      return $this->uri;
+
+    $this->uri = new lmbUri();
+    $this->uri->setProtocol($this->driver);
+    $this->uri->setHost($this->host);
+    $this->uri->setUser($this->user);
+    $this->uri->setPassword($this->password);
+    $this->uri->setPath('/' . $this->database);
+
+    if(isset($this->port))
+      $this->uri->setPort($this->port);
+    if(count($this->extra))
+      $this->uri->setQueryItems($this->extra);
+
+    return $this->uri;
+  }
+
+  function get($name)
+  {
+    $value = parent :: get($name);
+
+    if(isset($value))
+      return $value;
+
+    if(isset($this->extra[$name]))
+      return $this->extra[$name];
+  }
+
+  function toString()
+  {
+    return $this->_getUri()->toString();
+  }
+}
+
+?>



More information about the limb-svn mailing list