dbname = places #1
[live : general]
[dev : general]
[test : general]
db.config.dbname = places_test #2 (annotation) <#1 The default database to connect to is called ???places???.>
(annotation) <#2 When running unit tests, we need to control what is in the database, so a different one is used.>
The only thing we need to set up at this point is the connection to the database. The test section is for use
when using automatic testing of our application. Whilst we are testing, we don??™t want to touch our main
database, so we use a separate database that we can overwrite at will whilst testing different scenarios.
We will load our INI file in the bootstrap and then register it to the Zend Registry class so that the config data
can be retrieved wherever we need it:
// load configuration
$section = getenv('PLACES_CONFIG') ? getenv('PLACES_CONFIG') : 'live';
$config = new Zend_Config_Ini('./application/config.ini', $section);
Zend_Registry::set('config', $config);
In order to ensure that we load the correct section, we use an environment variable ???PLACES_CONFIG???.
This is set on a per server basis using the Apache configuration command setenv PLACE_CONFIG
{section_name}. For my development server, I therefore have configured my Apache configuration with
setenv PLACE_CONFIG dev and on the live site, we would use setenv PLACE_CONFIG live.
Pages:
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94