From 7e9263ff5c0f0f0593deb386aacf4043b43e70e2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 12 Nov 2013 18:51:02 +0100 Subject: SQL : Suppression requêtes SELECT inutile avant UPDATE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suppression requête SELECT avant UPDATE entry.is_favorite --- app/controllers/entryController.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'app/controllers/entryController.php') diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index 4c9eb9d1b..7ac9c4c0b 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -72,25 +72,12 @@ class entryController extends ActionController { $this->redirect = true; $id = Request::param ('id'); - $is_fav = Request::param ('is_favorite'); - - if ($is_fav) { - $is_fav = true; - } else { - $is_fav = false; - } - - $entryDAO = new EntryDAO (); - if ($id != false) { - $entry = $entryDAO->searchById ($id); - - if ($entry != false) { - $values = array ( - 'is_favorite' => $is_fav, - ); - - $entryDAO->updateEntry ($entry->id (), $values); - } + if ($id) { + $entryDAO = new EntryDAO (); + $values = array ( + 'is_favorite' => (bool)($is_fav = Request::param ('is_favorite')), + ); + $entryDAO->updateEntry ($id, $values); } } -- cgit v1.2.3