From 84b13d3d2642ad79369b33772c31c3e51d46d36f Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 14 Jul 2011 00:30:05 +0300 Subject: Added MainDb::one() --- MainApp.php | 11 ++++++----- MainDb.php | 6 ++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/MainApp.php b/MainApp.php index a74c6d4..0e79f96 100644 --- a/MainApp.php +++ b/MainApp.php @@ -35,8 +35,8 @@ class MainApp // dispatch requested controller $controller = self::classname($controller); - $c = new $controller(); - + $c = new $controller; +// var_dump($c); // assume no method name was given, try $param // URL format is always controller/param/action if (method_exists($c, $action)) { @@ -144,7 +144,7 @@ class MainApp static function error($msg) { $err = array('error' => $msg); - header('HTTP/1.0 500 Internal Server Error'); +// header('HTTP/1.0 500 Internal Server Error'); // send it to the browser //self::json($err); //trigger_error($msg, E_USER_NOTICE); @@ -335,7 +335,8 @@ class MainApp } $lang_file_content = file_get_contents($lang_file); - /* Load the language file as a JSON object and transform it into an associative array */ + /* Load the language file as a JSON object + and transform it into an associative array */ $translations = json_decode($lang_file_content, TRUE); } @@ -353,7 +354,7 @@ class MainApp function __autoload($name) { $class_name = MainApp::classname($name); - + include_once "{$class_name}.php"; if (!class_exists($class_name)) { diff --git a/MainDb.php b/MainDb.php index e1f293b..1f9401a 100644 --- a/MainDb.php +++ b/MainDb.php @@ -62,6 +62,12 @@ class MainDb trigger_error('Cloning disabled', E_USER_ERROR); } + public function one($sql, $data = NULL) + { + $result = self::fetch($sql, $data); + return current($result); + } + //// // execute an SQL query // @return mixed -- cgit v1.2.3