I have a function to delete a row from my table and I like to return true if the row existed before. I use the following function achieve that:
$mysqli = $this->mysqli;
$stmt = $mysqli->prepare("DELETE FROM active_clients WHERE token LIKE ?");
$stmt->bind_param('s', $token);
$stmt->execute();
if($stmt->affected_rows < 1){
$stmt->close();
return false;
}
$stmt->close();
return true;
It also worked propperly on my local host but when I moved to live server it doesn't return the correct result. affected_rows returns always 0 but the row is deleted as it should be. How can it be? Could there be a problem with php-version? I run locally 5.4 and on live server 5.3... Or ist it also possible that it has something to do with database or server configuration?