Mysql PDO execute always return true, even if i do a wrong query:
try {
$sql = $this->db->prepare("INSERT INTO orders (total_price) VALUES ('not_int');");
$result = $sql->execute(); // WHY TRUE??
} catch (Exception $e) {
die("Oh noes! There's an error in the query!");
}
In table, type of column 'total_price' is INT. Exception also not catch (PDO::ATTR_ERRMODE is PDO::ERRMODE_EXCEPTION). In 'total_price' inserts '0'. I'm try to use:
$total_price = "not_int";
$is_int = $sql->bindParam(:total_price, $total_price, PDO::PARAM_INT);
but also returns TRUE ($is_int is true)