Thanks a lot Simon!
I'm afraid to hear that Zend_Config ignores any element attribute.
Perhaps this is because of its SimpleXML origin. I'm not certain on this.
Anyway, I come up with:
Config.xml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<?xml version="1.0" encoding="UTF-8"?>
<config>
<production>
<database>
<type>mysqli</type>
<settings>
<host>localhost</host>
<port>3306</port>
<username>root</username>
<password></password>
<dbname></dbname>
</settings>
</database>
<debug>TRUE</debug>
</production>
</config>
Bootstraper
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ...
$db = Zend_Db::factory(
$config->database->type,
$config->database->settings->toArray()
);
$db->getConnection();
Anyone knows what is the best way to catch exceptions in ZF?
I've heard that we can catch the all exceptions in one place, for
example, at the top of the application. But how? and what is the
top of the application?
On 7/20/07, Simon Mundy <[EMAIL PROTECTED]> wrote:
Zend_Config ignores any element attributes. You'd be better off adding
<type>mysqli</type>
and then passing it across like:-
$db = Zend_Db::factory($config->database->type,
$config->database->toArray());
Hi,
Suppose we have an XML file like the following one:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<production>
<database type="mysqli">
<host>localhost</host>
<port>3306</port>
<username>root</username>
<password></password>
<dbname></dbname>
</database>
<debug>TRUE</debug>
</production>
</config>
Note that the 'database' has a 'type' attribute.
How can I read the type attribute of database?
$config = new Zend_Config_Xml('./application/config.xml', 'production',
FALSE);
echo($config->database->sec->value); // returns NULL
echo($config->database->sec); // returns NULL
Both return NULL!
--
Simon Mundy | Director | PEPTOLAB
""" " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
http://www.peptolab.com