diff options
author | Filipp Lepalaan <filipp@mekanisti.fi> | 2009-10-28 22:20:29 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mekanisti.fi> | 2009-10-28 22:20:29 +0200 |
commit | beadd930059012ddc6d055c09932227993305604 (patch) | |
tree | bd89671a5587dd7ed61631c4391244c3fa1bf5b0 /Controller.php | |
parent | 3036cdccec95ea8653f4925427a08c60e6233a36 (diff) | |
parent | 4a7a8168743588ac37b81fbfe5e27677a67749ce (diff) | |
download | main-beadd930059012ddc6d055c09932227993305604.tar.gz main-beadd930059012ddc6d055c09932227993305604.tar.bz2 main-beadd930059012ddc6d055c09932227993305604.zip |
Fixed conflicts
Diffstat (limited to 'Controller.php')
-rw-r--r-- | Controller.php | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/Controller.php b/Controller.php index 84947b0..22dccc6 100644 --- a/Controller.php +++ b/Controller.php @@ -221,14 +221,9 @@ class Controller * Insert this thing in the DB and return inserted * thing */ - public function insert($data = null) + public function insert($data) { - if (!$data) { - $data = $_POST; - } - if (empty($data)) { - App::log("Attempted to insert empty data"); return App::error("Nothing to insert"); } @@ -252,17 +247,17 @@ class Controller /** * Delete this thing */ - public function delete() + protected function delete($where) { - if (empty($_POST)) { - exit(App::error("Delete without arguments")); + if (empty($where)) { + return App::error("Delete without arguments"); } - list($key, $value) = each($_POST); - - $sql = "DELETE FROM `{$this->table}` WHERE `{$key}` = ?"; + list($key, $value) = each($where); + $data = array(":{$key}" => $value); + $sql = "DELETE FROM `{$this->table}` WHERE `{$key}` = :{$key}"; - return DB::query($sql, $value); + return Db::query($sql, $data); } @@ -271,13 +266,9 @@ class Controller * We keep this in the Controller since it might know * more about the topmost class */ - public function update($data = null, $where = null) + protected function update($data, $where = null) { - if (!$data) { - $data = $_POST; - } - - if (empty($data)) { + if (!is_array($data)) { return App::error("Update with empty parameters"); } |