Re: autoLoad and DataObjects revisited

From: Date: Fri, 29 Apr 2005 16:18:50 +0000
Subject: Re: autoLoad and DataObjects revisited
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19020@lists.php.net to get a copy of this message
On 4/28/05, pear@electroteque.org <pear@electroteque.org> wrote: > absolutely no go, my autoLoad looks like this > > function __autoLoad($classname) { > @require_once preg_replace("_","/",$classname)'.php'; > } > > however a do of DataObjects_Table_name gets called as u would expect > > DataObjects/Table/name.php :) > > must think of a better way > > it would be nice if __autoLoad could be handled class by class basis not > globally. > 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'; } } -- Justin Patrin

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