Hi,
I am looking at the Pear Primer by Joe Stump (article on phpbuilder), and having trouble getting it working correctly. The problems I am running into are with the error logging systems. It appears to log errors using two methods, PEAR_Error and Log::factory.
I am using PHP 4.3, using the default pear libraries, and have been running into problems with errors not registering in syslog, and not being reflected upwards thru the classes. An example of this is, changing the DSN in the Base.php class should report upwards.. however, from what I can understand, User.php, calls the base function with
function User($userID = 0)
{
$this->Base();
This does not seem to capture any connection errors, so the User function blindly continues to run, causing other errors.
I've tried using code like this, which catches the error.
function User($userID = 0)
{
if (!$this->Base()) {
return false;
}
and modified the Base class to return false if it could not connect, like this:
$this->db =& DB::connect(BASE_PEAR_DSN,true);
if(DB::isError($this->db))
{
$this = new PEAR_Error($this->db->getMessage());
return false;
}
I am fairly new to pear, so would like to know if there is a better way, using PEAR_Error. Attached is the full source I am working with. Idea's anyone of the best way to do this stuff?