Re: Re: Discussion of method -- config files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$reqdApplicFilesArray is not a global array [as in $GLOBALS]; it's simply a convenient way to list the variables I want to be globally available. The simple foreach defines them.


Robert Cummings wrote:
On Fri, 2008-06-20 at 11:32 -0400, Al wrote:
Not so Robert, here's how I typically handle such situations.

$reqdApplicFilesArray = array(// *Required application files and define() value
'regAdminSettings.db' => 'ADMIN_SETTINGS_FILE',
'regMemberData.db' => 'MEMBER_DATA_FILE',
'emailCellSettings.db' => 'EMAIL_CELL_SETTINGS_FILE',
);

foreach($reqdApplicFilesArray as $file => $defineContant)
{define($defineContant, $file);}

So you double declare your configuration data? Once as a global array,
and a second time as broken out constants? How do you loop over
configuration data? For instance I define multiple aliases databases and
perform a lookup into the database configuration via the key:

$GLOBALS['interJinn']['databases'] = array
(
    'db1' => array( /* config */ ),
    'db2' => array( /* config */ ),
    'db3' => array( /* config */ ),
    'db4' => array( /* config */ ),
);

Then request it:

$db = &$mDb->getConnection( 'db1' );

Which would lookup the db:

if( isset( $GLOBALS['interJinn']['databases'][$dbKey] ) )
{
    $config = $GLOBALS['interJinn']['databases'][$dbKey];
}

This is a gross oversimplification of what happens, but essentially a
lookup occurs at some point. It seems with constants I'd have to do some
fancy string concatenation and checking for defined constants via
dynamically built strings since each database configuration would be
broken out into a set of scalar constant.

I never did like constants for configuration, I never saw what they
brought to the table. I see their role for enumerating datatypes or
naming constant values within code, but not for configuration of said
code.

Cheers,
Rob.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux