|
From: Ben C. <php...@be...> - 2001-08-29 20:51:37
|
Oh, I did leave out the alternative of having two sets of names... P_xxx_TABLE has the TABLE_PREFIX prepended and xxx_TABLE does not. That would avoid TABLE_PREFIX. showing up everywhere in the code. On Wed, Aug 29, 2001 at 10:36:50PM +0200, Javier Sixto wrote: > Ben Curtis wrote: > > >Argh, some of my own code foiling my plans... :) For this case we really > >need to have the TABLE_PREFIX (if that's the constant) be separate from > >xxx_TABLE or $TABLE['xxx'] (depending on whether we use a constant or hash > >(if you think of them as roughly equivalent (which the developer purist in > >me doesn't, but I digress (ooh the parentheses nesting)))). So that means > >that queries throughout the code will either look like "select * from ". > >PREFIX ."table where ..." or "select * from ". PREFIX.xxx_TABLE ." where > >..." or "select * from ". PREFIX.$TABLE['xxx'] ." where ...". That way you > >have the PREFIXless table names for this array. > > > >Now as for the hash vs. constant decision, I really prefer constants for > >two reasons: > >1. These values are constant, so by definition they should be constants. :) > > > ok :-) the global variable is not very intersting for constants :-P > > > > >2. If it's a variable you have to remember to global $TABLE almost > >everywhere in the code. Since I almost always forget to global $STRING > >when I need to, this one is a big deal for me. :) > > > >So, even though the query lines are going to get noticeably longer, I > >prefer to set up TABLE_PREFIX and xxx_TABLE constants (e.g, > >define(USER_TABLE, 'auth_user')) and then have queries like "select * from > >". TABLE_PREFIX.USER_TABLE ." where user_id = blah". > > > I will follow you ;-) > > > > >Comments? Revilings? Letters to CAP_ABUSE@? :) > > > >On Wed, Aug 29, 2001 at 08:56:03PM +0200, Patrick Mairif wrote: > > > >>I found a construct in bug.php (line 81) in which the old tablenames are > >>used to access table fields in a loop, so I need a way to dynamically map > >>the old names to the new configured ones, a hash for instance. So I would > >>prefer Javiers solution and use one global hash and one constant for the > >>prefix. At this point I need it anyway. > >> > >>Other ideas? > >> > > > >_______________________________________________ > >phpbt-dev mailing list > >php...@li... > >http://lists.sourceforge.net/lists/listinfo/phpbt-dev > > > > > > > _______________________________________________ > phpbt-dev mailing list > php...@li... > http://lists.sourceforge.net/lists/listinfo/phpbt-dev |