public function delete() { Context::get('db')->start_transaction(); // delete blog comment BlogComment::neo()->where('blog_id = ?', $this->id)->delete(); // delete blog parent::delete(); Context::get('db')->commit(); }
public function leave() { // get nickname to say good bye. $user = User::neo()->where(User::get_login_id())->find(); // get all blog ids to delete comments $blogs = Blog::neo()->select('id')->where('user_id = ?', User::get_login_id())->find('all'); $blog_ids = extract_property($blogs, 'id'); // delete blog_comment, blog, and user Context::get('db')->start_transaction(); BlogComment::neo()->where('blog_id ' . Query::id_condition($blog_ids))->delete(); Blog::neo()->where('user_id = ?', User::get_login_id())->delete(); User::neo()->where(User::get_login_id())->delete(); Context::get('db')->commit(); $user->logout(); $this->redirect_to('/user/leave_success/' . $user->nickname); }
public function delete_comment($id) { $comment = BlogComment::neo()->where($id)->find(); // validation if (!$comment->validate_delete()) { $this->flash->add('message_error', $comment->errors->get_messages()); $this->back(); } $comment->delete(); $this->back(); }