|
From: Javier S. <js...@si...> - 2001-08-29 20:35:43
|
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 > |