mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
9a8d5c15fe
Revision: [2009] Adding fixes for session errors posted in the google group. Changed the header for PHP version in the model classes. Change uses() back to require_once Revision: [2008] Adding reference back to the PHP 4 model Revision: [2007] Merging changes from model_php5 Revision: [2006] Fixing recursive associations, adding whitelist to Model::save Revision: [2005] Added fix for error in CakeSession class. Updated home.thtml Revision: [2004] Rearranged some of the defines moving the most often changed ones to the top of the script Revision: [2003] Moved SQL files distributed with the core to app/config/sql/ Removed app/config/routes.php.default Fixed class_exists check in TextHelper Revision: [2002] adding sql directory Revision: [2001] Fixed error when cake distribution is installed inside of the DOCUMENT ROOT Revision: [2000] Adding checks for classes that are already loaded so the require() calls will not error Revision: [1999] Replacing all require_once() with require() Revision: [1998] Moved creation of the Dispatcher object to app/webroot/index.php Revision: [1997] Adding session sql file Revision: [1996] Revision: [1995] Fixing session db queries Revision: [1994] Change the require_once in bootstrap to require. Merged changes John made to the CakeSession database methods Revision: [1993] Removing some constants that are not needed Revision: [1992] Adding fix for Ticket #400 Revision: [1991] Fixing Ticket #348 Revision: [1990] Fixing Tickets #397 and #399 Revision: [1989] Fixed callbacks in JavaScript events and Ajax, fixed Controller::beforeRender so you can set view variables, and fixed Ticket #394 Revision: [1988] Renamed the $dir param to $direction. Added default value to the DboSource::order() $direction param. Revision: [1987] Adding changes back to the sessions class I reverted in [1984] git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2010 3807eeeb-6ff5-0310-8944-8be069107fe0
148 lines
No EOL
3.6 KiB
PHP
148 lines
No EOL
3.6 KiB
PHP
<?php
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
* Short description for file.
|
|
*
|
|
* Long description for file
|
|
*
|
|
* PHP versions 4 and 5
|
|
*
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
|
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
* Las Vegas, Nevada 89104
|
|
*
|
|
* Licensed under The MIT License
|
|
* Redistributions of files must retain the above copyright notice.
|
|
*
|
|
* @filesource
|
|
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
|
* @package cake
|
|
* @subpackage cake.cake.libs.model
|
|
* @since CakePHP v 0.10.x.1402
|
|
* @version $Revision$
|
|
* @modifiedby $LastChangedBy$
|
|
* @lastmodified $Date$
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
*/
|
|
|
|
/**
|
|
* Manages loaded instances of DataSource objects
|
|
*
|
|
* Long description for file
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.cake.libs.model
|
|
* @since CakePHP v 0.10.x.1402
|
|
*
|
|
*/
|
|
|
|
uses('model'.DS.'datasources'.DS.'datasource');
|
|
class ConnectionManager extends Object
|
|
{
|
|
|
|
/**
|
|
* Holds a loaded instance of the Connections object
|
|
*
|
|
* @var class:Connections
|
|
* @access public
|
|
*/
|
|
var $config = null;
|
|
|
|
/**
|
|
* Holds instances DataSource objects
|
|
*
|
|
* @var array
|
|
* @access private
|
|
*/
|
|
var $_dataSources = array();
|
|
|
|
/**
|
|
* Constructor.
|
|
*
|
|
*/
|
|
function __construct()
|
|
{
|
|
if(class_exists('DATABASE_CONFIG'))
|
|
{
|
|
$this->config = new DATABASE_CONFIG();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gets a reference to the ConnectionManger object instance
|
|
*
|
|
* @return object
|
|
*/
|
|
function &getInstance()
|
|
{
|
|
static $instance = array();
|
|
if(!isset($instance[0]) || !$instance[0])
|
|
{
|
|
$instance[0] =& new ConnectionManager();
|
|
}
|
|
return $instance[0];
|
|
}
|
|
|
|
/**
|
|
* Gets a reference to a DataSource object
|
|
*
|
|
* @param string $name The name of the DataSource, as defined in app/config/connections
|
|
* @return object
|
|
*/
|
|
function &getDataSource($name)
|
|
{
|
|
$_this =& ConnectionManager::getInstance();
|
|
|
|
if(in_array($name, array_keys($_this->_dataSources)))
|
|
{
|
|
return $_this->_dataSources[$name];
|
|
}
|
|
|
|
if(in_array($name, array_keys(get_object_vars($_this->config))))
|
|
{
|
|
$config = $_this->config->{$name};
|
|
|
|
if(isset($config['driver']) && $config['driver'] != null && $config['driver'] != '')
|
|
{
|
|
$filename = 'dbo_'.$config['driver'];
|
|
$classname = Inflector::camelize(strtolower('DBO_'.$config['driver']));
|
|
}
|
|
else
|
|
{
|
|
$filename = $config['datasource'].'_source';
|
|
$classname = Inflector::camelize(strtolower($config['datasource'].'_source'));
|
|
}
|
|
|
|
$tail = 'dbo'.DS.$filename.'.php';
|
|
if(!class_exists($classname))
|
|
{
|
|
if (fileExistsInPath(LIBS.'model'.DS.$tail))
|
|
{
|
|
require(LIBS.'model'.DS.$tail);
|
|
}
|
|
else if (file_exists(MODELS.$tail))
|
|
{
|
|
require(MODELS.$tail);
|
|
}
|
|
else
|
|
{
|
|
trigger_error('Unable to load model file ' . $filename . '.php', E_USER_ERROR);
|
|
return null;
|
|
}
|
|
}
|
|
$_this->_dataSources[$name] =& new $classname($config);
|
|
$_this->_dataSources[$name]->configKeyName = $name;
|
|
}
|
|
else
|
|
{
|
|
trigger_error("ConnectionManager::getDataSource - Non-existent data source {$name}", E_USER_ERROR);
|
|
return null;
|
|
}
|
|
return $_this->_dataSources[$name];
|
|
}
|
|
}
|
|
|
|
?>
|