Reorganize classes to autoload by namespace

This commit is contained in:
Timothy Warren 2014-08-08 13:48:20 -04:00
parent c65c7129a7
commit dd672df81d
12 changed files with 13 additions and 26 deletions

View File

@ -618,8 +618,6 @@ abstract class Abstract_Query_Builder {
$sql = $this->sql->explain($sql);
}
// $sql . "<br />";
return $sql;
}
}

View File

@ -231,4 +231,4 @@ final class Connection_Manager {
return $dsn;
}
}
// End of connection_manager.php
// End of connection_manager.php

View File

@ -51,12 +51,6 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
*/
public $util;
/**
* Reference to table_builder class
* @var \Query\Table\Table_Builder
*/
public $table;
/**
* Last query executed
* @var string

View File

@ -35,45 +35,40 @@ define('QDRIVER_PATH', QBASE_PATH.'drivers/');
// Require some common functions
require(QBASE_PATH.'common.php');
require(QBASE_PATH.'core/BadDBDriverException.php');
// Load Query Classes
spl_autoload_register(function ($class)
{
$class_segments = explode('\\', $class);
$class = strtolower(array_pop($class_segments));
$driver_class = strtolower(array_pop($class_segments));
// Load DB Driver classes
$driver_path = QDRIVER_PATH . "{$class}";
$driver_path = QDRIVER_PATH . "{$driver_class}";
if ($class_segments == array('Query', 'Driver') && is_dir($driver_path))
{
// Firebird is a special case, since it's not a PDO driver
// @codeCoverageIgnoreStart
if (
in_array($class, \PDO::getAvailableDrivers())
|| function_exists('\\fbird_connect') && $class === 'firebird'
in_array($driver_class, \PDO::getAvailableDrivers())
|| function_exists('\\fbird_connect') && $driver_class === 'firebird'
)
{
array_map('\\do_include', glob("{$driver_path}/*.php"));
}
// @codeCoverageIgnoreEnd
}
// Load other classes
foreach(array(
QBASE_PATH . "core/interfaces/{$class}.php",
QBASE_PATH . "core/abstract/{$class}.php",
QBASE_PATH . "core/{$class}.php"
) as $path)
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$file = QBASE_PATH . "{$path}.php";
// @codeCoverageIgnoreStart
if (file_exists($file))
{
// @codeCoverageIgnoreStart
if (file_exists($path))
{
require_once($path);
}
// @codeCoverageIgnoreEnd
require_once($file);
}
// @codeCoverageIgnoreEnd
});
// End of autoload.php