Prev | Current Page 80 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

Consider an INI file called config.ini containing the following:
[db]
adapter = PDO_MYSQL
database.host = localhost
database.username = user1234
database.password = 1234
database.name = db_one
This file is loaded and data can then be accessed like this:
$config = new Zend_Config_Ini('config.ini', 'db');
$adapter = $config->adapter;
$databaseHost = $config->database->host;
Note how the ???.??? within the key name of a setting is automatically turned into a hierarchical separator by
Zend_Config. This allows us to group our config data easily within the confines of the INI file format. Another
extension to the INI format that Zend_Config supports is section inheritance using the colon character (???:???) as
a separator within the section name. This allows for defining a base set of configuration settings and then
changing them based on which section is the master section as shown in Listing 3.1.
Listing 3.1 Example Zend_Config INI file.
[general]
db.adapter = PDO_MYSQL #1
db.config.host = localhost
db.config.username = user1234
db.config.password = 1234
db.config.dbname = db_one
[live : general] #2
db.config.host = livedb.example.com
[dev : general]
db.config.host = devdb.example.com
(annotation) <#1 The ???.??? In db.adapater means that adapter is a child of db.


Pages:
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
Wczasy nad morzem Gabi meble Warszawa kasyno Biuro księgowe Lublin noclegi zakopane