What I have learned is with PHP4, the error is caught if set_error_handler() has is set; nothing special needed to be done at the source of the error. However, with PHP5, I have to use try() / catch(). This makes the PHP5 code version dependent. Below, the use of try()/catch() works. I would like to have comments on this to find out if I am doing something incorrect.
PHP5:
function open($dbserver, $user, $password, $database) {
$dbh = new COM("ADODB.Connection");
$dsn = "DRIVER={SQL Server}; SERVER=" . $dbserver . ";UID=" . $user . ";PWD=" . $password . "; DATABASE=" . $database;
try {
$dbh->Open($dsn);
$this->dbh = $dbh;
} catch (Exception $e ){
trigger_error($e->getMessage());
}
}
PHP4:
function open($dbserver, $user, $password, $database) {
$dbh = new COM("ADODB.Connection");
$dsn = "DRIVER={SQL Server}; SERVER=" . $dbserver . ";UID=" . $user . ";PWD=" . $password . "; DATABASE=" . $database;
$dbh->Open($dsn);
if (!$dbh) $this->error = $this->dbh->Errors[0];
else $this->dbh = $dbh;
}