Location: PHPKode > scripts > Persist Class > persist-class/persistclass/dbconnection/DbConnectionPool.php
<?php

class DbConnectionPool {

	private static $instance = null;
	private $pool;

	private function __construct() {
		$this->pool = array();	
	}
	
	public static function instance() {
		if(is_null(self::$instance))
			self::$instance = new DbConnectionPool();
		return self::$instance;
	}
	
	public function registerConnection($dbConnection, $name = null) {
		$this->pool[$name] = $dbConnection;
	}
	
	public function getConnection($name = null) {
		if(!array_key_exists($name, $this->pool))
			throw new ConnectionException($name);
		return $this->pool[$name]->cloneConnection();
	}
}



?>
Return current item: Persist Class