php - Codeigniter delete a row -
i'm beginner in codeigniter.i'm trying delete row table.i tried following code.but it's not working.
this url i'm passing.
<a href="./delete_user/<?= $thisid ?>">delete user</a>
this controller (delete_user.php).
<?php defined('basepath') or exit('no direct script access allowed'); class delete_user extends ci_controller { public function delete_row($id) { $this->load->model('delete_selecteduser'); $where = array('id' => $id); $this->delete_selecteduser->delete_user('users', $where); }
and here model (delete_selecteduser.php).
<?php class delete_selecteduser extends ci_model { public function __construct() { $this->load->database(); } public function delete_user($table, $where = array()) { $this->db->where($where); $res = $this->db->delete($table); if ($res) return true; else return false; } }
and want display message record has been deleted successfully.please me fix this.
i suggest function must
public function delete_user($table, $where = array()) { $this->db->where($where); $this->db->delete($table); $res = $this->db->affected_rows(); return $res; }
in way have answer, 0
no deleted row or 1
if delete row
Comments
Post a Comment