Move abstract classes and interfaces to their own respective folders

This commit is contained in:
Timothy Warren 2014-04-02 22:40:54 -04:00
parent bccea8cd2b
commit 600c07f1ca
7 changed files with 36 additions and 20 deletions

View File

@ -44,26 +44,42 @@ function query_autoload($class)
{
$class_segments = explode('\\', $class);
$class = strtolower(array_pop($class_segments));
// Load Firebird separately
if (function_exists('fbird_connect') && $class === 'firebird')
// Load DB Driver classes
if ($class_segments == array('Query', 'Driver'))
{
array_map('do_include', glob(QDRIVER_PATH.'/firebird/*.php'));
return;
}
$class_path = QBASE_PATH . "classes/{$class}.php";
$driver_path = QDRIVER_PATH . "{$class}";
if (is_file($class_path)) require_once($class_path);
elseif (is_dir($driver_path))
{
$class = str_replace("pdo_", "", $class);
if (in_array($class, PDO::getAvailableDrivers()))
$driver_path = QDRIVER_PATH . "{$class}";
// @codeCoverageIgnoreStart
if (is_dir($driver_path))
{
array_map('do_include', glob("{$driver_path}/*.php"));
// Firebird is a special case, since it's not a PDO driver
if (
in_array($class, PDO::getAvailableDrivers())
|| function_exists('fbird_connect') && $class === 'firebird'
)
{
array_map('do_include', glob("{$driver_path}/*.php"));
return;
}
}
// @codeCoverageIgnoreEnd
}
// Load other classes
foreach(array(
QBASE_PATH . "classes/interfaces/{$class}.php",
QBASE_PATH . "classes/abstract/{$class}.php",
QBASE_PATH . "classes/{$class}.php"
) as $path)
{
if (file_exists($path))
{
// @codeCoverageIgnoreStart
require_once($path);
return;
// @codeCoverageIgnoreEnd
}
}
}

View File

@ -77,7 +77,7 @@ function db_filter($array, $index)
/**
* Connection function
*
* @param mixed $params
* @param string|object|array $params
* @return Query_Builder
*/
function Query($params = '')
@ -89,7 +89,7 @@ function Query($params = '')
{
return $cmanager->get_connection($params);
}
elseif ( ! is_scalar($params))
elseif ( ! is_scalar($params) && ! is_null($params))
{
$params = new ArrayObject($params, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);