Source for file ConnectorFactory.php
Documentation is available at ConnectorFactory.php
///////////////////////////////////////////////////////////////////////////////
* Include this file in your application to use the Connector library.
* Normally, there is no need to include any other files from the Connector
* library. Call the static {@link ConnectorFactory::create()} method to get
* an IConnector instance with an open database connection.
* <li>The supported PHP database extensions.</li>
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* The Connector library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* {@link http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License}
* @author Per Egil Roksvaag
* @copyright 2009 Per Egil Roksvaag
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
///////////////////////////////////////////////////////////////////////////////
* Include the IConnector interface.
require_once("IConnector.php");
///////////////////////////////////////////////////////////////////////////////
* Include this file in your application to use the Connector library.
* Normally, there is no need to include any other files from the Connector
* library. Call the static {@link ConnectorFactory::create()} method to get
* an IConnector instance with an open database connection.
///////////////////////////////////////////////////////////////////////////
* @var array An associated array of initialized IConnector instances.
static private $cache =
array();
///////////////////////////////////////////////////////////////////////////
* Include and create an instance of the selected IConnector class.
* If an IConnector instance with identical classname and connection
* parameters already exists, the existing instance is returned. If the
* classname is unknown or an error occurs, null is returend.
* IMPORTANT: Only use IConnector constants in the <var>$connection</var>
* and <var>$options</var> parameters. <b>No native constants</b> are
* available before this function has completed.
* @param string $classname The name of the IConnector class to use as a database connector.
* @param array $connection An associated array of connection settings.
* @param array $options An associated array of global options.
* @return IConnector A new or existing IConnector instance with an open database connection.
static public function create($classname, $connection, $options =
array())
$instance =
self::$cache[$hash];
$instance->setOptions($options);
case "PdoConnector":
require_once("PdoConnector.php"); break;
case "OdbcConnector":
require_once("OdbcConnector.php"); break;
case "MysqlConnector":
require_once("MysqlConnector.php"); break;
case "MssqlConnector":
require_once("MssqlConnector.php"); break;
case "SqlsrvConnector":
require_once("SqlsrvConnector.php"); break;
$instance =
new $classname($connection, $options);
self::$cache[$hash] =
$instance;
///////////////////////////////////////////////////////////////////////////
Documentation generated on Wed, 03 Jun 2009 12:41:51 +0200 by phpDocumentor 1.4.1