this is a piece of code
public static function delete_ques($ques_id) {
$con = Connection::get_Connection();
$sql_delete = "DELETE FROM question WHERE ques_id = " . $ques_id;
$result_delete = $con->query($sql_delete);
if ($result_delete->rowCount()) {
$con->close();
echo 'hell not ';
return true;
} else {
$con->close();
echo 'hell yes';
return false;
}
}
i cannot figure it out why its happening
The problem you are facing is because of rowCount(). according to php.net
rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding PDOStatement object.
In your situation i would use affected_rows. So you if-else code block would be like this
if ($con->affected_rows) {
$con->close();
echo 'hell not ';
return true;
} else {
$con->close();
echo 'hell yes';
return false;
}