diff options
author | Michael Tänzer <neo@nhng.de> | 2010-04-29 21:55:57 +0200 |
---|---|---|
committer | Michael Tänzer <neo@nhng.de> | 2010-04-29 21:55:57 +0200 |
commit | 727e4ff282623ce71df6c3700debf75029e5eb41 (patch) | |
tree | 51622f59cf19e4f4e50edaad4125a2757149d3dc /manager | |
parent | e9d2e83670f66050455efda3e17c58c374adf894 (diff) | |
download | cacert-mgr-727e4ff282623ce71df6c3700debf75029e5eb41.tar.gz cacert-mgr-727e4ff282623ce71df6c3700debf75029e5eb41.tar.xz cacert-mgr-727e4ff282623ce71df6c3700debf75029e5eb41.zip |
db->update() sucks for complicated where clauses
Signed-off-by: Michael Tänzer <neo@nhng.de>
Diffstat (limited to 'manager')
-rw-r--r-- | manager/application/controllers/AddPointsController.php | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/manager/application/controllers/AddPointsController.php b/manager/application/controllers/AddPointsController.php index b7f3541..7003e41 100644 --- a/manager/application/controllers/AddPointsController.php +++ b/manager/application/controllers/AddPointsController.php @@ -102,17 +102,16 @@ class AddPointsController extends Zend_Controller_Action // Fix the assurer flag - $where = array(); - $query = '`users`.`id` = ?'; - $where[] = $this->db->quoteInto($query, $user['id']); - $query = 'exists(select * from `cats_passed` as `cp`, ' . - '`cats_variant` as `cv` where `cp`.`variant_id` = `cv`.`id` and ' . - '`cv`.`type_id` = 1 and `cp`.`user_id` = ?'; - $where[] = $this->db->quoteInto($query, $user['id']); - $query = '(select sum(`points`) from `notary` where `to`= ? and ' . - '`expire` > now()) >= 100'; - $where[] = $this->db->quoteInto($query, $user['id']); - $this->db->update('users', array('assurer' => 1), $where); + $query = 'UPDATE `users` SET `assurer` = 1 WHERE `users`.`id` = :user AND '. + + 'EXISTS(SELECT * FROM `cats_passed` AS `cp`, `cats_variant` AS `cv` '. + 'WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND '. + '`cp`.`user_id` = :user) AND '. + + '(SELECT SUM(`points`) FROM `notary` WHERE `to` = :user AND '. + '`expire` < now()) >= 100'; + $query_params['user'] = $user['id']; + $this->db->query($query, $query_params); return; } |