mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
01b0d81dd2
- vendor() function to load a vendor library - uses() is simple again - config() treats database config differently (needs to because database config is a class, not a great idea after all) - moved DBO layers into their own subfolder in /libs -- there's too many of them already - AdoDB and Pear::DB support much better, although needs testing - fixes in Flay URL parsing - Model::findAll() uses the new DBO::selectLimit() method for wider database compatibility - changed Template::_page_title into _pageTitle - /public/index.php cleaned up git-svn-id: https://svn.cakephp.org/repo/trunk/cake@245 3807eeeb-6ff5-0310-8944-8be069107fe0
90 lines
No EOL
2.7 KiB
PHP
90 lines
No EOL
2.7 KiB
PHP
<?PHP
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// + $Id$
|
|
// +------------------------------------------------------------------+ //
|
|
// + Cake <https://developers.nextco.com/cake/> + //
|
|
// + Copyright: (c) 2005, Cake Authors/Developers + //
|
|
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
|
|
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
|
|
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
|
|
// +------------------------------------------------------------------+ //
|
|
// + Licensed under The MIT License + //
|
|
// + Redistributions of files must retain the above copyright notice. + //
|
|
// + See: http://www.opensource.org/licenses/mit-license.php + //
|
|
//////////////////////////////////////////////////////////////////////////
|
|
/**
|
|
* Purpose: DbFactory
|
|
*
|
|
* Description:
|
|
* Creates DBO-descendant objects from a given db connection configuration
|
|
*
|
|
* @filesource
|
|
* @author Cake Authors/Developers
|
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
|
* @version $Revision$
|
|
* @modifiedby $LastChangedBy$
|
|
* @lastmodified $Date$
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
*/
|
|
|
|
/**
|
|
* Enter description here...
|
|
*
|
|
*/
|
|
uses('object', 'dbo');
|
|
config('database');
|
|
|
|
/**
|
|
* Enter description here...
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.libs
|
|
* @since Cake v 1.0.0.0
|
|
*
|
|
*/
|
|
class DboFactory extends Object {
|
|
|
|
/**
|
|
* Enter description here...
|
|
*
|
|
* @param unknown_type $activeConfig
|
|
* @return unknown
|
|
*/
|
|
function make ($activeConfig) {
|
|
if (!class_exists('DATABASE_CONFIG')) return false;
|
|
|
|
$config = DATABASE_CONFIG::$activeConfig();
|
|
|
|
// special case for AdoDB -- driver name in the form of 'adodb-drivername'
|
|
if (preg_match('#^adodb[\-_](.*)$#i', $config['driver'], $res)) {
|
|
uses('dbo/dbo_adodb');
|
|
$config['driver'] = $res[1];
|
|
$conn = new DBO_AdoDB($config);
|
|
return $conn;
|
|
}
|
|
// special case for PEAR:DB -- driver name in the form of 'pear-drivername'
|
|
elseif (preg_match('#^pear[\-_](.*)$#i', $config['driver'], $res)) {
|
|
uses('dbo/dbo_pear');
|
|
$config['driver'] = $res[1];
|
|
$conn = new DBO_Pear($config);
|
|
return $conn;
|
|
}
|
|
// regular, Cake-native db drivers
|
|
else {
|
|
$db_driver_class = 'DBO_'.$config['driver'];
|
|
$db_driver_fn = LIBS.strtolower('dbo'.DS.$db_driver_class.'.php');
|
|
|
|
if (file_exists($db_driver_fn)) {
|
|
uses(strtolower('dbo'.DS.$db_driver_class));
|
|
return new $db_driver_class ($config);
|
|
}
|
|
else {
|
|
trigger_error (ERROR_UNKNOWN_DATABASE_DRIVER, E_USER_ERROR);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|