Reputation: 75
Here is my code:
try
{
oci_execute($command);
}
catch(Exception $e){
$this->sendMailFunction($e);
}
where $command
is a Oracle SQL Query. My Question is, if the query fails, the control is not going into the catch block. Why is it so?
I am using yii framework of php.
Upvotes: 2
Views: 5631
Reputation: 13024
oci_execute
doesn't throw Exceptions. If it fails, boolean false
will be returned and a Warning
will be generated. To get the error details you'll need to call the oci_error()
function instead of try/catch
:
if (false === oci_execute($command)) {
$this->sendMailFunction(oci_error($command));
};
If you don't want the Warning
in your error log you can prepend a @
sign to suppress it.
Upvotes: 3