Best way to configure DB_DataObject?
| From: | Phil Gyford | Date: | Mon, 13 Feb 2006 13:32:18 +0000 |
| Subject: | Best way to configure DB_DataObject? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-22947@lists.php.net to get a copy of this message | ||
Hi,
I'm using DB_DataObject and setting its options as suggested in the
documentation:
$options = &PEAR::getStaticProperty('DB_DataObject','options');
$options = array(
'database' => 'mysql://user:password@localhost/vending',
'schema_location' => '/home/me/Projects/myapplication/DataObjects',
'class_location' => '/home/me/Projects/myapplication/DataObjects',
'require_prefix' => 'DataObjects/',
'class_prefix' => 'DataObjects_',
);
However, I've noticed that if something is up with the database, eg,
connections refused or the password changes, then an error message is
displayed to the screen, which includes the DSN (I have display_errors and
display_startup_errors set to 0).
I can suppress this error by setting dont_die=>true in the options, but I'd
prefer to die gracefully, displaying an error to the user, rather than a
blank screen. How can I do this? I've tried looking at DB_DataObject's
LastError property with no joy.
I have a custom error handling function that usually works fine, but I can't
see how to detect for an error here and then use that function...?
Thanks,
Phil