From a42c754c31761767cd1ca6dcfe416671409f5435 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sat, 22 May 2010 01:09:22 +0300 Subject: Fix --- MainApp.php | 4 ++-- MainController.php | 31 +++++++++++++++---------------- config.default.ini | 12 ++++++++++++ 3 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 config.default.ini diff --git a/MainApp.php b/MainApp.php index e55a74a..6007bd0 100644 --- a/MainApp.php +++ b/MainApp.php @@ -8,7 +8,7 @@ class MainApp //// // Fire up the application static public function init() - { + { @list($controller, $param, $action) = App::url(); // no action given, read default one @@ -81,7 +81,7 @@ class MainApp if (!file_exists($cpath)) { trigger_error('Failed to open config file', E_USER_ERROR); - exit(); + return false; } $config = parse_ini_file($cpath, true); diff --git a/MainController.php b/MainController.php index e1545b7..ed8d5e6 100644 --- a/MainController.php +++ b/MainController.php @@ -8,16 +8,16 @@ class MainController public $pageTitle = ''; // Title of the rendered page public $defaultAction = ''; // Method to run when none specified - const OrderBy = ""; - const HasMany = ""; - const TableName = ""; - const ManyToMany = ""; - const ForeignKey = ""; - const TableSelect = ""; + const OrderBy = ''; + const HasMany = ''; + const TableName = ''; + const ManyToMany = ''; + const ForeignKey = ''; + const TableSelect = ''; function __construct($id = null) { - // Child classes should always have the same name as their tables + // child classes should always have the same name as their tables $this->class = get_class($this); $this->table = eval("return {$this->class}::TableName;"); @@ -38,9 +38,8 @@ class MainController } - /** - * Get One Thing - */ + //// + // Get One Thing public function get($where) { if (!is_array($where)) { @@ -62,7 +61,7 @@ class MainController */ public function find($where = null, $sort = false, $limit = false) { - $select = "*"; $q = ""; + $select = '*'; $q = ''; // Allow custom queries if (is_array($where)) @@ -70,18 +69,18 @@ class MainController foreach ($where as $k => $v) { $values[] = $v; - $args = explode(" ", $k); + $args = explode(' ', $k); $col = array_shift($args); - $op = implode(" ", $args); + $op = implode(' ', $args); // No column name given, default to "id" if (empty($col)) { - $col = "id"; + $col = 'id'; } // No operator given, default to "=" if (empty($op)) { - $op = "="; + $op = '='; } $tmp = (empty($q)) ? ' WHERE ' : ' AND '; @@ -94,7 +93,7 @@ class MainController } if ($where == null) { - $q = "WHERE ?"; + $q = 'WHERE ?'; $values = array(1); } diff --git a/config.default.ini b/config.default.ini new file mode 100644 index 0000000..68c97ce --- /dev/null +++ b/config.default.ini @@ -0,0 +1,12 @@ +[development] +db.name = servo +db.driver = mysql +db.host = localhost +db.username = servo +db.password = + +app.timezone = Europe/Helsinki +app.error_log = error.log + +defaults.controller = session +defaults.action = check -- cgit v1.2.3