From 1f8410794c8213d87227fabae2114a3be8033ece Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 18 May 2006 08:16:21 +0000 Subject: Moved adodb to 3rdParty directory. --- framework/DataAccess/TDatabaseProvider.php | 40 ++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'framework/DataAccess/TDatabaseProvider.php') diff --git a/framework/DataAccess/TDatabaseProvider.php b/framework/DataAccess/TDatabaseProvider.php index ac637d83..2a62c03a 100644 --- a/framework/DataAccess/TDatabaseProvider.php +++ b/framework/DataAccess/TDatabaseProvider.php @@ -52,11 +52,16 @@ abstract class TDatabaseProvider extends TModule } /** + * If the driver is sqlite, the host must be dot path to the sqlite + * file. * @return string the DB host name/IP (and port number) in the format "host[:port]" */ public function getHost() { - return $this->_host; + if(strtolower($this->getDriver()) == "sqlite") + return Prado::getPathOfNamespace($this->_host); + else + return $this->_host; } /** @@ -136,6 +141,24 @@ abstract class TDatabaseProvider extends TModule $this->_persistent=$value; } + protected function buildDsn() + { + $driver = $this->getDriver().'://'; + $user = $this->getUsername(); + $pass = rawurlencode($this->getPassword()); + $pass = strlen($pass) > 0 ? ':'.$pass : $pass; + $host = $this->getHost().'/'; + if(strtolower($this->getDriver()) == 'sqlite') + $host = rawurlencode($host); + else + $host = '@'.$host; + $db = $this->getDatabase(); + $db = strlen($db) > 0 ? '/'.$db : $db; + $persist = $this->getUsePersistentConnection() ? '': '?persit'; + + return $driver.$user.$pass.$host.$persist; + } + /** * @return TDbConnection a database connection */ @@ -193,16 +216,6 @@ interface IDbConnection */ public function completeTransaction(); - /** - * Fail the current transaction. - */ - public function failTransaction(); - - /** - * @return boolean true if transaction has failed. - */ - public function getHasTransactionFailed(); - /** * Makes all changes made since the previous commit/rollback permanent and * releases any database locks. @@ -253,6 +266,11 @@ abstract class TDbConnection extends TComponent implements IDbConnection { return $this->_provider; } + + public function __destruct() + { + $this->close(); + } } ?> \ No newline at end of file -- cgit v1.2.3