From 4c1ac26452c0314f81f0415778788e28f62971e9 Mon Sep 17 00:00:00 2001 From: nestor Date: Wed, 7 Jan 2015 17:34:34 +0100 Subject: [PATCH] =?UTF-8?q?Resuelto:=20Acci=C3=B3n=20delete=20funciona=20c?= =?UTF-8?q?orrectamente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/core/modelo2.php | 10 ++++++---- application/modulos/songs/Csongs.php | 4 ++-- application/modulos/songs/Msongs.php | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/application/core/modelo2.php b/application/core/modelo2.php index c433d56..f4bb36f 100644 --- a/application/core/modelo2.php +++ b/application/core/modelo2.php @@ -171,12 +171,14 @@ function update ($table, $params){ $query->execute($array_parameters); } - function delete ($table, $params = null, $entity = false){ - if($params != null){ - $sql = "DELETE FROM $table WHERE id = :".$params[0]; + //eliminado parametro $entity de momento + function delete ($table, $song_id = 0){ + if($song_id != 0){ + $sql = "DELETE FROM $table WHERE id = ".$song_id; + //d($sql); $query = $this->db->prepare($sql); $clave = ":id"; - $valor = $params[0]; + $valor = $song_id; //d($valor); $parameters = array(); $parameters[$clave] = $valor; diff --git a/application/modulos/songs/Csongs.php b/application/modulos/songs/Csongs.php index 4c35088..c803a3b 100644 --- a/application/modulos/songs/Csongs.php +++ b/application/modulos/songs/Csongs.php @@ -64,9 +64,9 @@ public function deleteSong_action($song_id){ if (isset($song_id)) { // do deleteSong() in model/model.php $this->model->deleteSong("song",$song_id); - } + } - // where to go after song has been deleted + // redirect user to songs index page (as we don't have a song_id) header('location: ' . URL . 'songs/index'); } diff --git a/application/modulos/songs/Msongs.php b/application/modulos/songs/Msongs.php index 3376f97..4d4ba4a 100644 --- a/application/modulos/songs/Msongs.php +++ b/application/modulos/songs/Msongs.php @@ -39,9 +39,9 @@ public function addSong($table, $params) { * add/update/delete stuff! * @param int $song_id Id of song */ - public function deleteSong($table, $song_id, $entity = null){ + public function deleteSong($table, $song_id){ echo "Hola desde deleteSong"; - $this->delete($table, $song_id, $entity); + $this->delete($table, $song_id); } /**