Query/autoload.php

71 lines
1.6 KiB
PHP
Raw Normal View History

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