I'm getting data back from an AJAX call, which I then try and INSERT into a database. I'm using Silverstripe 3.1 (using DB::query()), but this seems to be a PHP thing.
If the transaction works then everything works as planned, however, if the query fails I get a PHP fatal error.
Basically I'm looking for a way to continue despite a fatal error so that I can throw a failed notification to a user. I'd just like to know if the query worked or not.
*Edit to include Code
$sql = "UPDATE $table SET ,,"; // Syntax error added purposefully
foreach ($update_array as $key => $value) {
$name = $formHelpers->some_filter($key);
$content = $formHelpers->some_filter($value);
$sql .= " $name='$content',";
}
$sql = rtrim($sql, ",");
$sql .= "WHERE id=$id";
$result = DB::query($sql);