How to find out the number of rows deleted in mysql?

How to find out the absence of deleted lines in codeigniter, provided that it $this->db->affected_rows()returns every time, i.e. to success or failure also

+3
source share
5 answers

How to find out if there are any deleted lines in codeigniter, provided that $ this-> db-> affected_rows () is returned every time, i.e. to success or failure also

I do not use CodeIgniter, but usually affected_rows( )should return the number of rows affected. This means that if the request was successful, it should always be an integer. If 0 is returned, rows are not deleted; if> 0, this number is deleted.

+2
source
$this->db->where($conditions)->delete('mytable');
return $this->db->affected_rows(); 
+3
source

Codeigniter userguide :

": MySQL" DELETE FROM TABLE " 0 . , . , ."

:

 $this->db->delete('1', 'your_table');
 echo ($this->db->affected_rows()." rows were deleted");

,

$count = $this->db->count_all('your_table');
$this->db->delete('1', 'your_table');
$new_count = $this->db->count_all('your_table');
if ($new_count > $count)
{
    echo (($new_count-$count)." rows was deleted");
}
else
{
    echo "nothing deleted";
}
+1

, , ... SELECT COUNT (*) , .

0

All Articles