diff --git a/autoload.php b/autoload.php index 83df138..5a97afc 100644 --- a/autoload.php +++ b/autoload.php @@ -42,20 +42,34 @@ if ( ! function_exists('do_include')) } } -// Load base classes -array_map('do_include', glob(QBASE_PATH.'classes/*.php')); - -// Load PDO Drivers -foreach(pdo_drivers() as $d) +/** + * Load a Query class + * + * @param string $class + */ +function query_autoload($class) { - $dir = QDRIVER_PATH.$d; + $class = strtolower($class); + $class_path = QBASE_PATH . "classes/{$class}.php"; + + $driver_path = QDRIVER_PATH . "{$class}"; - if(is_dir($dir)) + if (is_file($class_path)) { - array_map('do_include', glob($dir.'/*.php')); + require_once($class_path); + } + elseif (is_dir($driver_path)) + { + if (in_array($class, pdo_drivers())) + { + array_map('do_include', glob("{$driver_path}/*.php")); + } } } +// Set up autoloader +spl_autoload_register('query_autoload'); + // Load Firebird driver, if applicable if (function_exists('fbird_connect')) { diff --git a/docs/classes/DB_PDO.html b/docs/classes/DB_PDO.html index 47b5e26..b93475b 100644 --- a/docs/classes/DB_PDO.html +++ b/docs/classes/DB_PDO.html @@ -707,7 +707,7 @@ the connection/database
+ generated on 2012-05-21T15:17:51-04:00.