aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MainApp.php11
-rw-r--r--MainController.php5
-rw-r--r--MainDb.php4
3 files changed, 12 insertions, 8 deletions
diff --git a/MainApp.php b/MainApp.php
index ea148bb..73d3dc6 100644
--- a/MainApp.php
+++ b/MainApp.php
@@ -37,22 +37,25 @@ class MainApp
// dispatch requested controller
$controller = self::classname($controller);
$c = new $controller;
-// var_dump($c);
+
+ // try to determine passed argument
+ $a = (empty($_POST) && !empty($action)) ? $param : $_POST;
+
// assume no method name was given, try $param
// URL format is always controller/param/action
if (method_exists($c, $action)) {
- return $c->$action($_POST);
+ return $c->$action($a);
}
// controller/action
if (method_exists($c, $param)) {
- return $c->$param($_POST);
+ return $c->$param($a);
}
// ...then fall back to defaultAction
if (method_exists($c, $c->defaultAction)) {
$action = $c->defaultAction;
- return $c->$action($_POST);
+ return $c->$action($a);
}
// don't know what to do, giving up...
diff --git a/MainController.php b/MainController.php
index 17e7167..65ae757 100644
--- a/MainController.php
+++ b/MainController.php
@@ -367,8 +367,9 @@ class MainController
$val = implode(', ', array_keys($values));
$this->sql_insert = sprintf($this->sql_insert, $this->table, $insert, $val);
-
- return MainDb::query($this->sql_insert, $values);
+ $seq_id = sprintf( '%s_id_seq', strtolower(get_called_class()) );
+
+ return MainDb::query( $this->sql_insert, $values, $seq_id );
}
diff --git a/MainDb.php b/MainDb.php
index dba4e18..adbc00d 100644
--- a/MainDb.php
+++ b/MainDb.php
@@ -81,7 +81,7 @@ class MainDb
////
// execute an SQL query
// @return mixed
- public static function query($sql, $data = NULL)
+ public static function query($sql, $data = NULL, $seq_id = NULL)
{
$args = func_get_args();
$sql = array_shift($args);
@@ -153,7 +153,7 @@ class MainDb
}
if( empty( $data[':id'] )) {
- $data[':id'] = $pdo->lastInsertId('order_id_seq');
+ $data[':id'] = $pdo->lastInsertId( $seq_id );
}
$out = array();