根据Codigniter 用户guide ,它返回正确的行数:
"Note: In MySQL "DELETE FROM TABLE" returns 0 affected rows. The
database class has a small hack that allows it to return the correct
number of affected rows. By default this hack is enabled but it can be
turned off in the database driver file."
因此,这项工作应:
$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";
}