2014-04-15 16:13:18 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
|
|
|
* Free Query Builder / Database Abstraction Layer
|
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren
|
|
|
|
* @copyright Copyright (c) 2012 - 2014
|
|
|
|
* @link https://github.com/aviat4ion/Query
|
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Autoloader for loading available database classes
|
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
*/
|
|
|
|
|
2014-08-08 12:48:30 -04:00
|
|
|
namespace Query;
|
|
|
|
|
2014-04-15 16:13:18 -04:00
|
|
|
/**
|
|
|
|
* Reference to root path
|
|
|
|
* @subpackage Core
|
|
|
|
*/
|
|
|
|
define('QBASE_PATH', dirname(__FILE__).'/');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Path to driver classes
|
|
|
|
* @subpackage Core
|
|
|
|
*/
|
|
|
|
define('QDRIVER_PATH', QBASE_PATH.'drivers/');
|
|
|
|
|
|
|
|
// Require some common functions
|
|
|
|
require(QBASE_PATH.'common.php');
|
|
|
|
|
2014-08-08 12:48:30 -04:00
|
|
|
// Load Query Classes
|
|
|
|
spl_autoload_register(function ($class)
|
2014-04-15 16:13:18 -04:00
|
|
|
{
|
|
|
|
$class_segments = explode('\\', $class);
|
2014-08-08 13:50:55 -04:00
|
|
|
$driver_class = strtolower(array_pop($class_segments));
|
2014-04-15 16:13:18 -04:00
|
|
|
|
|
|
|
// Load DB Driver classes
|
2014-08-08 13:50:55 -04:00
|
|
|
$driver_path = QDRIVER_PATH . "{$driver_class}";
|
2014-04-15 16:13:18 -04:00
|
|
|
if ($class_segments == array('Query', 'Driver') && is_dir($driver_path))
|
|
|
|
{
|
|
|
|
|
|
|
|
// Firebird is a special case, since it's not a PDO driver
|
2014-08-08 12:48:30 -04:00
|
|
|
// @codeCoverageIgnoreStart
|
2014-04-15 16:13:18 -04:00
|
|
|
if (
|
2014-08-08 13:50:55 -04:00
|
|
|
in_array($driver_class, \PDO::getAvailableDrivers())
|
|
|
|
|| function_exists('\\fbird_connect') && $driver_class === 'firebird'
|
2014-04-15 16:13:18 -04:00
|
|
|
)
|
|
|
|
{
|
2014-08-08 12:48:30 -04:00
|
|
|
array_map('\\do_include', glob("{$driver_path}/*.php"));
|
2014-04-15 16:13:18 -04:00
|
|
|
}
|
2014-08-08 12:48:30 -04:00
|
|
|
// @codeCoverageIgnoreEnd
|
2014-04-15 16:13:18 -04:00
|
|
|
}
|
2014-08-08 13:50:55 -04:00
|
|
|
|
2014-04-15 16:13:18 -04:00
|
|
|
// Load other classes
|
2014-08-08 13:50:55 -04:00
|
|
|
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
|
|
|
|
$file = QBASE_PATH . "{$path}.php";
|
|
|
|
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
|
if (file_exists($file))
|
2014-04-15 16:13:18 -04:00
|
|
|
{
|
2014-08-08 13:50:55 -04:00
|
|
|
require_once($file);
|
2014-04-15 16:13:18 -04:00
|
|
|
}
|
2014-08-08 13:50:55 -04:00
|
|
|
// @codeCoverageIgnoreEnd
|
2014-08-08 12:48:30 -04:00
|
|
|
});
|
2014-04-15 16:13:18 -04:00
|
|
|
|
|
|
|
// End of autoload.php
|