aboutsummaryrefslogtreecommitdiffstats
path: root/MainController.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2011-05-13 12:36:58 +0300
committerFilipp Lepalaan <filipp@mac.com>2011-05-13 12:36:58 +0300
commitc63171e653c7bca1f8b23dede30e60d398de35ae (patch)
tree73b862e115a3fd042f7f8d59c01e934eb32b7996 /MainController.php
parentf18fe95d034a73bc7a93ca48860fb010a8e01011 (diff)
downloadmain-c63171e653c7bca1f8b23dede30e60d398de35ae.tar.gz
main-c63171e653c7bca1f8b23dede30e60d398de35ae.tar.bz2
main-c63171e653c7bca1f8b23dede30e60d398de35ae.zip
fixes
Diffstat (limited to 'MainController.php')
-rw-r--r--MainController.php27
1 files changed, 16 insertions, 11 deletions
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;
+ }
}
////