I have a php function much like this:
function add($db, $value) {
try {
$stmt = $db->prepare("INSERT INTO table(value) VALUES (?);");
$stmt->execute(array($value));
}
catch(PDOException $e) {
error_log($e->getMessage());
// Error handeling
}
}
If the query is successfull and there is no exception, shouldn't the function return TRUE?
The only way to get the function above return TRUE is if I modify the "try" section:
if ($stmt->execute(array($value))) {
return TRUE;
}
What am I missing?