1
- <?php
2
- if (!defined ('PHP_VERSION_ID ' ) || PHP_VERSION_ID < 50300 )
3
- die ('PHP ActiveRecord requires PHP 5.3 or higher ' );
4
-
5
- define ('PHP_ACTIVERECORD_VERSION_ID ' ,'1.0 ' );
6
-
7
- if (!defined ('PHP_ACTIVERECORD_AUTOLOAD_PREPEND ' ))
8
- define ('PHP_ACTIVERECORD_AUTOLOAD_PREPEND ' ,true );
9
-
10
- require __DIR__ .'/lib/Singleton.php ' ;
11
- require __DIR__ .'/lib/Config.php ' ;
12
- require __DIR__ .'/lib/Utils.php ' ;
13
- require __DIR__ .'/lib/DateTime.php ' ;
14
- require __DIR__ .'/lib/Model.php ' ;
15
- require __DIR__ .'/lib/Table.php ' ;
16
- require __DIR__ .'/lib/ConnectionManager.php ' ;
17
- require __DIR__ .'/lib/Connection.php ' ;
18
- require __DIR__ .'/lib/Serialization.php ' ;
19
- require __DIR__ .'/lib/SQLBuilder.php ' ;
20
- require __DIR__ .'/lib/Reflections.php ' ;
21
- require __DIR__ .'/lib/Inflector.php ' ;
22
- require __DIR__ .'/lib/CallBack.php ' ;
23
- require __DIR__ .'/lib/Exceptions.php ' ;
24
- require __DIR__ .'/lib/Cache.php ' ;
25
-
26
- if (!defined ('PHP_ACTIVERECORD_AUTOLOAD_DISABLE ' ))
27
- spl_autoload_register ('activerecord_autoload ' ,false ,PHP_ACTIVERECORD_AUTOLOAD_PREPEND );
28
-
29
- function activerecord_autoload ($ class_name )
30
- {
31
- $ path = ActiveRecord \Config::instance ()->get_model_directory ();
32
- $ root = realpath (isset ($ path ) ? $ path : '. ' );
33
-
34
- if (($ namespaces = ActiveRecord \get_namespaces ($ class_name )))
35
- {
36
- $ class_name = array_pop ($ namespaces );
37
- $ directories = array ();
38
-
39
- foreach ($ namespaces as $ directory )
40
- $ directories [] = $ directory ;
41
-
42
- $ root .= DIRECTORY_SEPARATOR . implode ($ directories , DIRECTORY_SEPARATOR );
43
- }
44
-
45
- $ file = "$ root/ $ class_name.php " ;
46
-
47
- if (file_exists ($ file ))
48
- require_once $ file ;
49
- }
1
+ <?php
2
+ if (!defined ('PHP_VERSION_ID ' ) || PHP_VERSION_ID < 50300 )
3
+ die ('PHP ActiveRecord requires PHP 5.3 or higher ' );
4
+
5
+ define ('PHP_ACTIVERECORD_VERSION_ID ' , '1.0 ' );
6
+
7
+ if (!defined ('PHP_ACTIVERECORD_AUTOLOAD_PREPEND ' ))
8
+ define ('PHP_ACTIVERECORD_AUTOLOAD_PREPEND ' , true );
9
+
10
+ require __DIR__ .'/lib/Singleton.php ' ;
11
+ require __DIR__ .'/lib/Config.php ' ;
12
+ require __DIR__ .'/lib/Utils.php ' ;
13
+ require __DIR__ .'/lib/DateTime.php ' ;
14
+ require __DIR__ .'/lib/Model.php ' ;
15
+ require __DIR__ .'/lib/Table.php ' ;
16
+ require __DIR__ .'/lib/ConnectionManager.php ' ;
17
+ require __DIR__ .'/lib/Connection.php ' ;
18
+ require __DIR__ .'/lib/Serialization.php ' ;
19
+ require __DIR__ .'/lib/SQLBuilder.php ' ;
20
+ require __DIR__ .'/lib/Reflections.php ' ;
21
+ require __DIR__ .'/lib/Inflector.php ' ;
22
+ require __DIR__ .'/lib/CallBack.php ' ;
23
+ require __DIR__ .'/lib/Exceptions.php ' ;
24
+ require __DIR__ .'/lib/Cache.php ' ;
25
+
26
+ if (!defined ('PHP_ACTIVERECORD_AUTOLOAD_DISABLE ' ))
27
+ spl_autoload_register ('activerecord_autoload ' , false , PHP_ACTIVERECORD_AUTOLOAD_PREPEND );
28
+
29
+ function activerecord_autoload ($ class_name )
30
+ {
31
+ $ path = ActiveRecord \Config::instance ()->get_model_directory ();
32
+ $ root = realpath (isset ($ path ) ? $ path : '. ' );
33
+
34
+ if (($ namespaces = ActiveRecord \get_namespaces ($ class_name )))
35
+ {
36
+ $ class_name = array_pop ($ namespaces );
37
+ $ directories = array ();
38
+
39
+ foreach ($ namespaces as $ directory )
40
+ $ directories [] = $ directory ;
41
+
42
+ $ root .= DIRECTORY_SEPARATOR . implode ($ directories , DIRECTORY_SEPARATOR );
43
+ }
44
+
45
+ $ file = "$ root/ $ class_name.php " ;
46
+
47
+ if (file_exists ($ file ))
48
+ require_once $ file ;
49
+ }
0 commit comments