1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-11 08:34:59 +02:00

added NException

This commit is contained in:
David Grudl
2007-11-14 23:05:57 +00:00
parent 0eeff53fe8
commit 6bfa40f594
13 changed files with 135 additions and 41 deletions

View File

@@ -27,6 +27,7 @@
* - 'password' (or 'pass')
* - 'persistent' - try to find a persistent link?
* - 'database' - the database name to select
* - 'lazy' - if TRUE, connection will be established only when required
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl

View File

@@ -32,6 +32,7 @@
* - 'charset' - sets the encoding
* - 'unbuffered' - sends query without fetching and buffering the result rows automatically?
* - 'options' - driver specific constants (MYSQL_*)
* - 'lazy' - if TRUE, connection will be established only when required
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl
@@ -99,13 +100,13 @@ class DibiMySqlDriver extends NObject implements DibiDriverInterface
$host = ':' . $config['socket'];
}
DibiDatabaseException::catchError();
NException::catchError('DibiDatabaseException');
if (empty($config['persistent'])) {
$this->connection = @mysql_connect($host, $config['username'], $config['password'], TRUE, $config['options']);
} else {
$this->connection = @mysql_pconnect($host, $config['username'], $config['password'], $config['options']);
}
DibiDatabaseException::restore();
NException::restore();
if (!is_resource($this->connection)) {
throw new DibiDatabaseException(mysql_error(), mysql_errno());

View File

@@ -32,6 +32,7 @@
* - 'charset' - sets the encoding
* - 'unbuffered' - sends query without fetching and buffering the result rows automatically?
* - 'options' - driver specific constants (MYSQLI_*)
* - 'lazy' - if TRUE, connection will be established only when required
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl

View File

@@ -26,6 +26,7 @@
* - 'username' (or 'user')
* - 'password' (or 'pass')
* - 'persistent' - try to find a persistent link?
* - 'lazy' - if TRUE, connection will be established only when required
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl

View File

@@ -26,6 +26,7 @@
* - 'username' (or 'user')
* - 'password' (or 'pass')
* - 'charset' - sets the encoding
* - 'lazy' - if TRUE, connection will be established only when required
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl

View File

@@ -26,6 +26,7 @@
* - 'username' (or 'user')
* - 'password' (or 'pass')
* - 'options' - driver specific options array
* - 'lazy' - if TRUE, connection will be established only when required
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl

View File

@@ -25,6 +25,7 @@
* - 'database' (or 'string') - connection string
* - 'persistent' - try to find a persistent link?
* - 'charset' - sets the encoding
* - 'lazy' - if TRUE, connection will be established only when required
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl
@@ -65,13 +66,13 @@ class DibiPostgreDriver extends NObject implements DibiDriverInterface
}
DibiDatabaseException::catchError();
NException::catchError('DibiDatabaseException');
if (isset($config['persistent'])) {
$this->connection = @pg_connect($config['database'], PGSQL_CONNECT_FORCE_NEW);
} else {
$this->connection = @pg_pconnect($config['database'], PGSQL_CONNECT_FORCE_NEW);
}
DibiDatabaseException::restore();
NException::restore();
if (!is_resource($this->connection)) {
throw new DibiDatabaseException('unknown error');

View File

@@ -25,6 +25,7 @@
* - 'database' (or 'file') - the filename of the SQLite database
* - 'persistent' - try to find a persistent link?
* - 'unbuffered' - sends query without fetching and buffering the result rows automatically?
* - 'lazy' - if TRUE, connection will be established only when required
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl