From fd22c556391652c1cdb1b62631ec068f75ddec37 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 1 May 2008 21:56:20 +0000 Subject: [PATCH] DibiPdoDriver - new connection parameter "pdo" for PDO object passing --- dibi/drivers/pdo.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dibi/drivers/pdo.php b/dibi/drivers/pdo.php index e7c4a4a5..1595cb1e 100644 --- a/dibi/drivers/pdo.php +++ b/dibi/drivers/pdo.php @@ -26,6 +26,7 @@ * - 'username' (or 'user') * - 'password' (or 'pass') * - 'options' - driver specific options array + * - 'pdo' - PDO object (optional) * - 'lazy' - if TRUE, connection will be established only when required * * @author David Grudl @@ -81,10 +82,15 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver DibiConnection::alias($config, 'username', 'user'); DibiConnection::alias($config, 'password', 'pass'); DibiConnection::alias($config, 'dsn'); + DibiConnection::alias($config, 'pdo'); 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']); + } catch (PDOException $e) { throw new DibiDriverException($e->getMessage(), $e->getCode()); }