On Thu, 2008-06-19 at 18:37 +0300, Sancar Saran wrote:
> Well, after reaching this
>
> $GLOBALS['live']['current']['c']['modules']['traffics']['url'] = 'blah';
>
> I change my mind to use public static variables.
>
> using conf::$vars (or someting like that) was more pratic than using $GLOBALS
> directly. You can set config each of your classes.
So are you saying you instead do:
conf::$vars['current']['c']['modules']['traffics']['url'] = 'blah';
Or:
conf::$vars_current_c_modules_traffics_url = 'blah';
I fail to see how conf::x overcomes your problem. Also, why would you
write out the entire path like that in a configuration? Why not have the
entire configuration contained in one expression?
$GLOBALS['live'] = array
(
'current' => array
(
'c' => array
(
'modules' => array
(
'traffics' => array
(
'url' = 'blah',
),
),
),
),
);
Then adding an additional entry becomes trivial... for instance adding:
conf::$vars['current']['c']['modules']['traffics']['pass'] =
'kret';
Is trivial:
$GLOBALS['live'] = array
(
'current' => array
(
'c' => array
(
'modules' => array
(
'traffics' => array
(
'url' => 'blah',
'pass' => 'kret',
),
),
),
),
);
For instance... here's how I configure database connections:
$GLOBALS['interJinn']['databases'] = array
(
'namedDatabase' => array
(
'type' => 'mysql',
'host' => 'interjinn.com',
'user' => 'user',
'password' => 'password',
'db' => 'relevant_database',
),
'otherNamedDatabase' => array
(
'type' => 'mysql',
'host' => 'localhost',
'socket' => '/var/run/mysqld/mysqld.sock',
'user' => 'luser',
'password' => 'notSoSekret',
'db' => 'other_database',
),
'default' => 'namedDatabase',
);
Then in my code I can request a connection by name, or let it fall back
to the default, or if necessary request a connection with explicit
connection details. I never work with connection information beyond the
configuration. It's very convenient to be able to alias a database and
not worry about the specifics.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php