Re: DB_DataObject table prefix?

From: Date: Mon, 20 Dec 2004 17:49:58 +0000
Subject: Re: DB_DataObject table prefix?
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16346@lists.php.net to get a copy of this message
Alan Knowles, the lead (only dev, actually) for DB_DataObject. Actually, I just thought of one possible solution. You could make your own DO base class which extends DB_DataObject, then alter $this->__table in the constructor. class My_Base_DO extends DB_DataObject { function My_Base_DO() { $this->__table = $GLOBALS['_DB_DATAOBJECT']['CONFIG']['table_prefix'].$this->__table; } } Then extend all your table DOs from that one. This *should* work, althouh you would always have to run the generator on a "base" database without a prefix. On Mon, 20 Dec 2004 17:35:18 +0000, Phil Gyford <gyford@gmail.com> wrote: > Hi Justin, > > Sorry, I've been busy on other projects for a week or two... Who's > Alan? I'll follow up with him to see if he has any ideas, as there was > no other reply to the thread. > > Thanks, > Phil > > > On Wed, 8 Dec 2004 10:04:03 -0800, Justin Patrin <papercrane@gmail.com> wrote: > > On Wed, 8 Dec 2004 11:26:55 +0000, Phil Gyford <gyford@gmail.com> wrote: > > > Hi, > > > > > > Is it possible to specify a table prefix for tables used by DB_DataObject? > > > > > > I've just had to add prefixes to all the table names used by my > > > current project, and this of course means that DB_DataObject's > > > auto-building creates new class files with different names, which > > > means a lot of manual changes around the site. > > > > > > eg... My .ini had this in it: > > > > > > require_prefix = DataObjects/ > > > class_prefix = DataObjects_ > > > > > > and I had a table called 'person' and a class called > > > 'DataObjects_Person' in a Person.php file. > > > > > > After adding table prefixes I have a table called 'myproject_person' > > > and a class called 'DataObjects_Myproject_person' in a > > > Myproject_person.php file. > > > > > > I guess being able to put: > > > > > > table_prefix = Myproject_ > > > > > > in my .ini file would be ideal but I can't find anything like this in > > > the documentation. Any thoughts? > > > > > > > Great question. If an app was to allow table prefixes (as most apps > > do) DB_DataObject would be a failure without this feature.... I don't > > know the answer, but perhaps Alan does. ;-) > > > > > Phil > > > > > > > -- > > Justin Patrin > > > > > !DSPAM:41c70f5d90311127920713! > > -- Justin Patrin

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