Commit cdddf751 authored by zYne's avatar zYne

added contains

parent b23a69c1
...@@ -57,7 +57,14 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -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 * @var Doctrine_Null $null Doctrine_Null object, used for extremely fast null value checking
*/ */
private $null; private $null;
/**
* @var array $driverMap
*/
private $driverMap = array('oracle' => 'oci8',
'postgres' => 'pgsql',
'oci' => 'oci8',
'sqlite2' => 'sqlite',
'sqlite3' => 'sqlite');
/** /**
* constructor * constructor
* *
...@@ -171,6 +178,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -171,6 +178,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* @param PDO|Doctrine_Adapter_Interface $adapter database driver * @param PDO|Doctrine_Adapter_Interface $adapter database driver
* @param string $name name of the connection, if empty numeric key is used * @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 bind a connection with an existing name
* @throws Doctrine_Manager_Exception if trying to open connection for unknown driver
* @return Doctrine_Connection * @return Doctrine_Connection
*/ */
public function openConnection($adapter, $name = null, $setCurrent = true) public function openConnection($adapter, $name = null, $setCurrent = true)
...@@ -191,6 +199,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -191,6 +199,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$name = $this->index; $name = $this->index;
$this->index++; $this->index++;
} }
switch ($adapter->getAttribute(PDO::ATTR_DRIVER_NAME)) { switch ($adapter->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'mysql': case 'mysql':
$this->connections[$name] = new Doctrine_Connection_Mysql($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Mysql($this, $adapter);
...@@ -226,10 +235,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -226,10 +235,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
return $this->connections[$name]; return $this->connections[$name];
} }
public function openSession(PDO $pdo, $name = null)
{
return $this->openConnection($pdo, $name);
}
/** /**
* getConnection * getConnection
* @param integer $index * @param integer $index
...@@ -321,6 +326,17 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -321,6 +326,17 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
$this->currIndex = $key; $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 * count
* returns the number of opened connections * returns the number of opened connections
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment