hi guys, i come from a java background.
I find it quite peculiar that even with the introduction of try and catch blocks(and no finally??) for php, other built in functions of php does not automatically throw an exception. IS there any way to get around this? Even perl has the eval {} method that captures exception from its built in functions.
take for example, im trying to capture all oci errors, but i only throw exception at the end if theres any oci_error. if either one of those oci_bind_by_name doesn't work, it won't throw any exception but a warning, so i can't 'catch' it.
//let's say i have my statement ready as stmt :
try{
if($stmt){
if(oci_bind_by_name($stmt, ":FIELD_A", $subject))
if(oci_bind_by_name($stmt, ":FIELD_B", $subject))
if(oci_bind_by_name($stmt, ":FIELD_C", $subject)){
if(oci_execute($stmt, OCI_DEFAULT)){
oci_commit($conn);
} else {
oci_rollback($conn);
}
}
oci_free_statement($stmt);
//capture connection error and throw if found
if(oci_error()) {
$err = oci_error($conn);
throw new Exception($err['message']);
}
}
}
catch{
//do something here
}