aboutsummaryrefslogtreecommitdiffstats
path: root/Controller.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mekanisti.fi>2009-10-27 09:19:29 +0200
committerFilipp Lepalaan <filipp@mekanisti.fi>2009-10-27 09:19:29 +0200
commit78112fa3ee94f7f29f842f82fac992c9e6bd236f (patch)
tree8badae5afbbe541b7e315a23cadc95da7f47b1b9 /Controller.php
parent64cfbcf3dc766a5bbe80b74072c4686fd956bc53 (diff)
downloadmain-78112fa3ee94f7f29f842f82fac992c9e6bd236f.tar.gz
main-78112fa3ee94f7f29f842f82fac992c9e6bd236f.tar.bz2
main-78112fa3ee94f7f29f842f82fac992c9e6bd236f.zip
More fixes
Diffstat (limited to 'Controller.php')
-rw-r--r--Controller.php28
1 files changed, 9 insertions, 19 deletions
diff --git a/Controller.php b/Controller.php
index d5813a1..e25c575 100644
--- a/Controller.php
+++ b/Controller.php
@@ -107,7 +107,7 @@ class Controller
$sql .= " LIMIT $limit";
}
- $result = DB::query($sql, $values)->fetchAll(PDO::FETCH_ASSOC);
+ $result = DB::fetch($sql, $values);
for ($i=0; $i < count($result); $i++)
{
@@ -216,14 +216,9 @@ class Controller
* Insert this thing in the DB and return inserted
* thing
*/
- public function insert($data = null)
+ public function insert()
{
- if (!$data) {
- $data = $_POST;
- }
-
if (empty($data)) {
- App::log("Attempted to insert empty data");
return App::error("Nothing to insert");
}
@@ -247,17 +242,16 @@ 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);
+ list($key, $value) = each($where);
$sql = "DELETE FROM `{$this->table}` WHERE `{$key}` = ?";
-
- return DB::query($sql, $value);
+ return Db::query($sql, array($value));
}
@@ -266,13 +260,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)
+ public function update($data, $where = null)
{
- if (!$data) {
- $data = $_POST;
- }
-
- if (empty($data)) {
+ if (!is_array($data)) {
return App::error("Update with empty parameters");
}