public function delete($id) { $Blog = new Blog($this->plural_resource); $sql = $Blog->destroy($id); mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); header("Location: ../index"); }
public function delete($id) { $Blog = new Blog($this->table_name, $this->action); $sql = $Blog->destroy($id); mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); header("Location: ../index"); }
public function deleteAction() { // make sure they own it $Blog = new Blog($this->_db, new User($this->_db, $_SESSION['user']['id'])); $post = $Blog->find(array('id' => abs($_GET['id']))); if (empty($post[0]) || $post[0]['users_id'] != $_SESSION['user']['id']) { $this->_template->hud = array('class' => 'error', 'message' => 'You do not own this post!'); return false; } if ($Blog->destroy($_GET['id'])) { $this->forward('index', array('class' => 'success', 'message' => 'The post was removed!')); } else { $this->_template->hud = array('class' => 'error', 'message' => 'There was a problem removing the post!'); } }