Location: PHPKode > projects > POP - Persistent Objects for PHP > POP/core/POPDB.php
<?php

	/**
	 * Class used for creating the database connections for the POP lib
	 * 
	 * @package pop
	 * @subpackage core
	 */
	abstract class POPDB
	{
		/**
		 * Connection collection
		 * @var array
		 */
		protected static $conns;
		
		/**
		 * Add a connection to the collection
		 * @param $conn_name - Name for the connection
		 * @param $driver - Driver
		 * @param $server - Server name/IP
		 * @param $dbname - Database name
		 * @param $user - Database User
		 * @param $password - User password
		 * @return void
		 */
		public static function addConnection($conn_name, $driver, $server, $dbname, $user, $password)
		{
			if (!is_array(self::$conns))
				self::$conns = array();
			
			try
			{
				self::$conns[$conn_name] = POPDBDriverRegistry::getDriver($driver)->newConnection($server,$dbname,$user,$password);
			}
			catch (Exception $e)
			{
				POPDebug::exception("Error trying to connect ".$conn_name.": ".$e->getMessage());
			}
		}
		
		/**
		 * Get the connection
		 * @param $conn_name - Name of the connection
		 * @return PDO Object
		 */
		public static function getConnection($conn_name)
		{
			return self::$conns[$conn_name];
		}
		
	}
?>
Return current item: POP - Persistent Objects for PHP