Bill Karwin wrote:
$db = Zend_Db::factory($config->database->type, $config->database->params);
I'm unable to run the code, It seems that
you forgot to convert <params> from an object
to an array. Or perhpas I'm missing something?
On 7/20/07, Bill Karwin <[EMAIL PROTECTED]> wrote:
I would organize my config like this:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<production>
<database>
<type>mysqli</type>
<params>
<host>localhost</host>
<port>3306</port>
<username>root</username>
<password></password>
<dbname></dbname>
</params>
</database>
<debug>TRUE</debug>
</production>
</config>
Then it's easy to use like this:
$db = Zend_Db::factory($config->database->type,
$config->database->params);
Regards,
Bill Karwin
------------------------------
*From:* AmirBehzad Eslami [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 19, 2007 5:50 PM
*To:* [email protected]
*Subject:* [fw-general] [ZF-General] Reading from XML file using ConfigXML
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!