mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
DibiPdoDriver - new connection parameter "pdo" for PDO object passing
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
* - 'username' (or 'user')
|
* - 'username' (or 'user')
|
||||||
* - 'password' (or 'pass')
|
* - 'password' (or 'pass')
|
||||||
* - 'options' - driver specific options array
|
* - 'options' - driver specific options array
|
||||||
|
* - 'pdo' - PDO object (optional)
|
||||||
* - 'lazy' - if TRUE, connection will be established only when required
|
* - 'lazy' - if TRUE, connection will be established only when required
|
||||||
*
|
*
|
||||||
* @author David Grudl
|
* @author David Grudl
|
||||||
@@ -81,10 +82,15 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
|
|||||||
DibiConnection::alias($config, 'username', 'user');
|
DibiConnection::alias($config, 'username', 'user');
|
||||||
DibiConnection::alias($config, 'password', 'pass');
|
DibiConnection::alias($config, 'password', 'pass');
|
||||||
DibiConnection::alias($config, 'dsn');
|
DibiConnection::alias($config, 'dsn');
|
||||||
|
DibiConnection::alias($config, 'pdo');
|
||||||
DibiConnection::alias($config, 'options');
|
DibiConnection::alias($config, 'options');
|
||||||
|
|
||||||
try {
|
if ($config['pdo'] instanceof PDO) {
|
||||||
|
$this->connection = $config['pdo'];
|
||||||
|
|
||||||
|
} else try {
|
||||||
$this->connection = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
|
$this->connection = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
|
||||||
|
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
throw new DibiDriverException($e->getMessage(), $e->getCode());
|
throw new DibiDriverException($e->getMessage(), $e->getCode());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user