From c63171e653c7bca1f8b23dede30e60d398de35ae Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Fri, 13 May 2011 12:36:58 +0300 Subject: fixes --- MainController.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'MainController.php') diff --git a/MainController.php b/MainController.php index 381e1c1..da27b81 100644 --- a/MainController.php +++ b/MainController.php @@ -11,6 +11,7 @@ * To Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ + class MainController { public $view; // Where to store the data to be rendered @@ -18,8 +19,8 @@ class MainController public $defaultAction = ''; // Method to run when none specified - const OrderBy = ''; - const HasMany = ''; + const OrderBy = ''; // which column to order the results by + const HasMany = ''; const TableName = ''; const ManyToMany = ''; const ForeignKey = ''; @@ -81,22 +82,26 @@ class MainController public function init() { // populate indices - if ($_SESSION['config']['db.driver'] == 'mysql') { - $schema = MainDb::fetch('DESCRIBE `'.$this->table.'`'); - foreach ($schema as $s) { - $this->data[$s['Field']] = $s['Default']; - } - return $this; - } + $driver = MainApp::conf('db.driver'); - if ($_SESSION['config']['db.driver'] == 'sqlite') { + switch ($driver) { + case 'sqlite': $sql = 'PRAGMA TABLE_INFO('.$this->table.')'; $schema = MainDb::fetch($sql); foreach ($schema as $s) { $this->data[$s['name']] = ''; } - } return $this; + break; + + default: + $schema = MainDb::fetch('DESCRIBE `'.$this->table.'`'); + foreach ($schema as $s) { + $this->data[$s['Field']] = $s['Default']; + } + return $this; + break; + } } //// -- cgit v1.2.3