Axiom (v1.2.0)

A lightweight PHP framework
H:/Workspace/php-axiom/www/php-axiom/libraries/axiom/axDatabase.class.php
Go to the documentation of this file.
00001 <?php
00020 class axDatabase extends PDO {
00021     
00035     public function factory ($model, $id = null) {
00036         try {
00037             if (is_string($model) && strpos($model, '.') !== false) {
00038                 return new axMySQLObject($this, $model, $id);
00039             }
00040             elseif (class_exists($model, true)) {
00041                 if (!in_array('axModel', class_implements($model)))
00042                     throw new RuntimeException("Class `{$model}` doesn't implements `axModel`");
00043                 return new $model($this, $id);
00044             }
00045             else {
00046                 return new axMySQLObject($this, $model, $id);
00047             }
00048         }
00049         catch (Exception $e) {
00050             trigger_error("Cannot construct the {$model} model object: " . $e->getMessage(), E_USER_WARNING);
00051             return false;
00052         }
00053     }
00054     
00069     public function fetchAll ($model, array $search_params = array(), array $options = array()) {
00070         try {
00071             if (is_string($model) && strpos($model, '.') !== false) {
00072                 return axMySQLObject::all($this, $search_params, $options, $model);
00073             }
00074             elseif (class_exists($model, true)) {
00075                 if (!in_array('axModel', class_implements($model)))
00076                         throw new RuntimeException("Class `{$model}` doesn't implements `axModel`");
00077                 return call_user_func(array($model, 'all'), $this, $search_params, $options);
00078             }
00079             else {
00080                 return axMySQLObject::all($this, $search_params, $options, $model); 
00081             }
00082         }
00083         catch (Exception $e) {
00084             trigger_error("Cannot retrieve {$model} list: " . $e->getMessage(), E_USER_WARNING);
00085             return false;
00086         }
00087     }
00088 }
 All Data Structures Files Functions Variables