From 2c67dd03cc917bd0f83cfc53923f4e009edc39c5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 21 May 2012 15:18:06 -0400 Subject: [PATCH] Set up autoloader --- autoload.php | 30 ++++++++++++++++------ docs/classes/DB_PDO.html | 2 +- docs/classes/DB_Reg.html | 2 +- docs/classes/DB_SQL.html | 2 +- docs/classes/DB_Util.html | 2 +- docs/classes/Firebird.html | 2 +- docs/classes/Firebird_Result.html | 2 +- docs/classes/Firebird_SQL.html | 2 +- docs/classes/Firebird_Util.html | 2 +- docs/classes/MySQL.html | 2 +- docs/classes/MySQL_SQL.html | 2 +- docs/classes/MySQL_Util.html | 2 +- docs/classes/ODBC.html | 2 +- docs/classes/ODBC_SQL.html | 2 +- docs/classes/ODBC_Util.html | 2 +- docs/classes/PgSQL.html | 2 +- docs/classes/PgSQL_SQL.html | 2 +- docs/classes/PgSQL_Util.html | 2 +- docs/classes/Query_Builder.html | 2 +- docs/classes/SQLite.html | 2 +- docs/classes/SQLite_SQL.html | 2 +- docs/classes/SQLite_Util.html | 2 +- docs/classes/Settings.html | 2 +- docs/deprecated.html | 2 +- docs/errors.html | 2 +- docs/graph_class.html | 2 +- docs/markers.html | 2 +- docs/namespaces/default.html | 15 ++++++++++- docs/packages/.html | 2 +- docs/packages/Default.html | 2 +- docs/packages/Query.Drivers.html | 2 +- docs/packages/Query.Helper Classes.html | 2 +- docs/packages/Query.Query.html | 2 +- docs/packages/Query.html | 16 +++++++++++- docs/structure.xml | 32 ++++++++++++++++++------ tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 36 files changed, 106 insertions(+), 49 deletions(-) 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.
diff --git a/docs/classes/DB_Reg.html b/docs/classes/DB_Reg.html index 9ec2733..3bb2bdb 100644 --- a/docs/classes/DB_Reg.html +++ b/docs/classes/DB_Reg.html @@ -153,7 +153,7 @@ and organizes database connections

+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/DB_SQL.html b/docs/classes/DB_SQL.html index 24cc171..0d6f1fd 100644 --- a/docs/classes/DB_SQL.html +++ b/docs/classes/DB_SQL.html @@ -299,7 +299,7 @@ specified table
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/DB_Util.html b/docs/classes/DB_Util.html index 9bf546f..b17d3b6 100644 --- a/docs/classes/DB_Util.html +++ b/docs/classes/DB_Util.html @@ -210,7 +210,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/Firebird.html b/docs/classes/Firebird.html index 99f5247..4089a41 100644 --- a/docs/classes/Firebird.html +++ b/docs/classes/Firebird.html @@ -869,7 +869,7 @@ the last query executed
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/Firebird_Result.html b/docs/classes/Firebird_Result.html index 6000e8a..efad958 100644 --- a/docs/classes/Firebird_Result.html +++ b/docs/classes/Firebird_Result.html @@ -505,7 +505,7 @@ the query
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/Firebird_SQL.html b/docs/classes/Firebird_SQL.html index 49c413d..bb82d31 100644 --- a/docs/classes/Firebird_SQL.html +++ b/docs/classes/Firebird_SQL.html @@ -309,7 +309,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/Firebird_Util.html b/docs/classes/Firebird_Util.html index c820f9a..4c6ddd7 100644 --- a/docs/classes/Firebird_Util.html +++ b/docs/classes/Firebird_Util.html @@ -213,7 +213,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/MySQL.html b/docs/classes/MySQL.html index 1c81d42..bfa8162 100644 --- a/docs/classes/MySQL.html +++ b/docs/classes/MySQL.html @@ -905,7 +905,7 @@ the connection/database
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/MySQL_SQL.html b/docs/classes/MySQL_SQL.html index 6fda525..1cb574f 100644 --- a/docs/classes/MySQL_SQL.html +++ b/docs/classes/MySQL_SQL.html @@ -314,7 +314,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/MySQL_Util.html b/docs/classes/MySQL_Util.html index 8b31e63..1f97863 100644 --- a/docs/classes/MySQL_Util.html +++ b/docs/classes/MySQL_Util.html @@ -209,7 +209,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/ODBC.html b/docs/classes/ODBC.html index c23d4fa..8d4cb8b 100644 --- a/docs/classes/ODBC.html +++ b/docs/classes/ODBC.html @@ -907,7 +907,7 @@ the connection/database
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/ODBC_SQL.html b/docs/classes/ODBC_SQL.html index d30b2c3..88f4901 100644 --- a/docs/classes/ODBC_SQL.html +++ b/docs/classes/ODBC_SQL.html @@ -309,7 +309,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/ODBC_Util.html b/docs/classes/ODBC_Util.html index 07f662d..3a5d690 100644 --- a/docs/classes/ODBC_Util.html +++ b/docs/classes/ODBC_Util.html @@ -204,7 +204,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/PgSQL.html b/docs/classes/PgSQL.html index 2a062b4..b36b09a 100644 --- a/docs/classes/PgSQL.html +++ b/docs/classes/PgSQL.html @@ -907,7 +907,7 @@ the connection/database
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/PgSQL_SQL.html b/docs/classes/PgSQL_SQL.html index 34a505d..48fd549 100644 --- a/docs/classes/PgSQL_SQL.html +++ b/docs/classes/PgSQL_SQL.html @@ -309,7 +309,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/PgSQL_Util.html b/docs/classes/PgSQL_Util.html index 3705199..4b63942 100644 --- a/docs/classes/PgSQL_Util.html +++ b/docs/classes/PgSQL_Util.html @@ -209,7 +209,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/Query_Builder.html b/docs/classes/Query_Builder.html index ba2771b..250aa0c 100644 --- a/docs/classes/Query_Builder.html +++ b/docs/classes/Query_Builder.html @@ -1223,7 +1223,7 @@ for complex select queries
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/SQLite.html b/docs/classes/SQLite.html index 0d640ca..4de6770 100644 --- a/docs/classes/SQLite.html +++ b/docs/classes/SQLite.html @@ -922,7 +922,7 @@ method if the database does not support 'TRUNCATE';
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/SQLite_SQL.html b/docs/classes/SQLite_SQL.html index 5d4e09d..ea9fdfa 100644 --- a/docs/classes/SQLite_SQL.html +++ b/docs/classes/SQLite_SQL.html @@ -309,7 +309,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/SQLite_Util.html b/docs/classes/SQLite_Util.html index c5d90b9..c000070 100644 --- a/docs/classes/SQLite_Util.html +++ b/docs/classes/SQLite_Util.html @@ -209,7 +209,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/classes/Settings.html b/docs/classes/Settings.html index 706f04e..5ec22dc 100644 --- a/docs/classes/Settings.html +++ b/docs/classes/Settings.html @@ -245,7 +245,7 @@ directly - the settings should be safe!
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/deprecated.html b/docs/deprecated.html index d6ef411..7fe1eb0 100644 --- a/docs/deprecated.html +++ b/docs/deprecated.html @@ -68,7 +68,7 @@
+ generated on 2012-05-21T15:17:52-04:00.
diff --git a/docs/errors.html b/docs/errors.html index a03a3f2..efd3caf 100644 --- a/docs/errors.html +++ b/docs/errors.html @@ -94,7 +94,7 @@
+ generated on 2012-05-21T15:17:52-04:00.
diff --git a/docs/graph_class.html b/docs/graph_class.html index 6c4746c..6fd8535 100644 --- a/docs/graph_class.html +++ b/docs/graph_class.html @@ -65,7 +65,7 @@
+ generated on 2012-05-21T15:17:52-04:00.
diff --git a/docs/markers.html b/docs/markers.html index 3fa3153..694d417 100644 --- a/docs/markers.html +++ b/docs/markers.html @@ -164,7 +164,7 @@
+ generated on 2012-05-21T15:17:52-04:00.
diff --git a/docs/namespaces/default.html b/docs/namespaces/default.html index 3ece5d5..ddac196 100644 --- a/docs/namespaces/default.html +++ b/docs/namespaces/default.html @@ -106,6 +106,19 @@ with array_map and glob +
+

Load a Query class

+
query_autoload(string $class) 
+
+
+

+

Parameters

+
+

$class

+string +
+
+

Classes and interfaces

@@ -284,7 +297,7 @@ instantiates the specific db driver

+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/packages/.html b/docs/packages/.html index 1de505c..8e03dae 100644 --- a/docs/packages/.html +++ b/docs/packages/.html @@ -68,7 +68,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/packages/Default.html b/docs/packages/Default.html index 3c94c32..aafe62c 100644 --- a/docs/packages/Default.html +++ b/docs/packages/Default.html @@ -95,7 +95,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/packages/Query.Drivers.html b/docs/packages/Query.Drivers.html index d71700c..5d0565f 100644 --- a/docs/packages/Query.Drivers.html +++ b/docs/packages/Query.Drivers.html @@ -212,7 +212,7 @@ data-fetching methods

+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/packages/Query.Helper Classes.html b/docs/packages/Query.Helper Classes.html index c6598ea..7f8756b 100644 --- a/docs/packages/Query.Helper Classes.html +++ b/docs/packages/Query.Helper Classes.html @@ -98,7 +98,7 @@
+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/packages/Query.Query.html b/docs/packages/Query.Query.html index c3ed05f..cd17a66 100644 --- a/docs/packages/Query.Query.html +++ b/docs/packages/Query.Query.html @@ -116,7 +116,7 @@ instantiates the specific db driver

+ generated on 2012-05-21T15:17:51-04:00.
diff --git a/docs/packages/Query.html b/docs/packages/Query.html index 8b17e22..42ca765 100644 --- a/docs/packages/Query.html +++ b/docs/packages/Query.html @@ -77,6 +77,7 @@
  • Bulk directory loading workaround for use with array_map and glob
    do_include
  • +
  • Load a Query class
    query_autoload
  • @@ -122,6 +123,19 @@ with array_map and glob
    +
    +

    Load a Query class

    +
    query_autoload(string $class) 
    +
    +
    +

    +

    Parameters

    +
    +

    $class

    +string +
    +
    +