|
From: Patrick M. <mai...@st...> - 2001-08-30 08:04:19
|
I allready started a solution with an constant prefix and an array:
define ('DB_PREFIX', 'phpbt_');
$cfgDatabase['attachment'] = DB_PREFIX.'attachment');
the solution with only one prefix used everywhere would be another
possibility.
> 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. :)
> 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. :)
I made the same experience! now, there is everywhere a
'global $cfgDatabase'! :-)
> 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 need a dynamic mapping from the old tablenames, which are part of
fieldnames, to the new tablenames. I need a construct like
$cfgDatabase[$field]. With constants I have to create this kind of array
from the constants!
|