Re: autoLoad and DataObjects revisited

From: Date: Fri, 29 Apr 2005 21:41:12 +0000
Subject: Re: autoLoad and DataObjects revisited
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19024@lists.php.net to get a copy of this message
On 30/04/2005, at 2:18 AM, Justin Patrin wrote:
Is there a question here? BTW, you shouldn't be using preg_replace here, use str_replace. You can, of course, do it class by class. function __autoLoad($classname) { if (strncmp(strtolower($classname), 'dataobjects', 11) == 0) {
    $table = substr($classname, strpos($classname, '_') + 1);
    $options =& PEAR::getStaticProperty('DB_DataObject', 'options');
    require_once($options['require_prefix'].$table);
} else {
    @require_once str_replace('_','/',$classname)'.php';
} }
It was an addon to my last question to show my results, I was hoping to avoid any ifs in the loader. How do you load do's, using factory or require the file then load the DO class ? It looks like I also have to check to avoid loading DB_Error, for some freaky reason its trying to load the callback as DB_Error is in the same DB.php file and I cant work out where its being called from as yet. Dan

« previous php.pear.general (#19024) next »