From cdddf75112359fec67121ed818178382626f8ba7 Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 25 Jan 2007 21:40:40 +0000 Subject: [PATCH] added contains --- lib/Doctrine/Manager.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index c46a6e17b..7643e7c32 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -57,7 +57,14 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera * @var Doctrine_Null $null Doctrine_Null object, used for extremely fast null value checking */ private $null; - + /** + * @var array $driverMap + */ + private $driverMap = array('oracle' => 'oci8', + 'postgres' => 'pgsql', + 'oci' => 'oci8', + 'sqlite2' => 'sqlite', + 'sqlite3' => 'sqlite'); /** * constructor * @@ -171,6 +178,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera * @param PDO|Doctrine_Adapter_Interface $adapter database driver * @param string $name name of the connection, if empty numeric key is used * @throws Doctrine_Manager_Exception if trying to bind a connection with an existing name + * @throws Doctrine_Manager_Exception if trying to open connection for unknown driver * @return Doctrine_Connection */ public function openConnection($adapter, $name = null, $setCurrent = true) @@ -191,6 +199,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera $name = $this->index; $this->index++; } + switch ($adapter->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql': $this->connections[$name] = new Doctrine_Connection_Mysql($this, $adapter); @@ -226,10 +235,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera } return $this->connections[$name]; } - public function openSession(PDO $pdo, $name = null) - { - return $this->openConnection($pdo, $name); - } /** * getConnection * @param integer $index @@ -321,6 +326,17 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera } $this->currIndex = $key; } + /** + * contains + * whether or not the manager contains specified connection + * + * @param mixed $key the connection key + * @return boolean + */ + public function contains($key) + { + return isset($this->connections[$key]); + } /** * count * returns the number of opened connections