On Feb 6, 2008 11:22 AM, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
> -- Garri Santos <[EMAIL PROTECTED]> wrote
> (on Wednesday, 06 February 2008, 10:43 AM +0800):
> > Good Day,
> >
> > Im not sure anymore whether it's my xml file or is it Zend_Config_Xml
> has the
> > problem. Here's my xml file.
> >
> > config.xml
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <configuration>
> > <default>
> > <baseurl>/ubraa/public</baseurl>
> > <database>
> > <type>pdo_mysql</type>
> > <host>localhost</host>
> > <username>root</username>
> > <password>password</password>
> > <dbname>ubraa</dbname>
> > </database>
> > </default>
> > </configuration>
> >
> > After doing this:
> >
> > $this->config = new Zend_Config_Xml($this->ubraaRoot .
> DIRECTORY_SEPARATOR .
> > 'configuration' . DIRECTORY_SEPARATOR .
> > 'config.xml', 'default');
> >
> > The Zend_Db::factory($config->type, $config); is throwing me an error
>
> Um... shouldn't that be
>
> Zend_Db::factory($config->database->type, $config->database);
>
> ?
>
> Based on the structure of your XML, you're not pulling from the correct
> location in the config...
>
>
> > Adapter parameters must be in an array or a Zend_Config object
> >
> > I have var_dump($this->config->database) and these is the result:
> >
> > object(Zend_Config_Xml)#2 (6) {
> > ["_allowModifications:protected"]=>
> > bool(false)
> > ["_index:protected"]=>
> > int(0)
> > ["_count:protected"]=>
> > int(2)
> > ["_data:protected"]=>
> > array(2) {
> > ["baseurl"]=>
> > string(13) "/ubraa/public"
> > ["database"]=>
> > object(Zend_Config)#4 (6) {
> > ["_allowModifications:protected"]=>
> > bool(false)
> > ["_index:protected"]=>
> > int(0)
> > ["_count:protected"]=>
> > int(5)
> > ["_data:protected"]=>
> > array(5) {
> > ["type"]=>
> > string(9) "pdo_mysql"
> > ["host"]=>
> > string(9) "localhost"
> > ["username"]=>
> > string(4) "root"
> > ["password"]=>
> > string(8) "password"
> > ["dbname"]=>
> > string(5) "ubraa"
> > }
> > ["_loadedSection:protected"]=>
> > NULL
> > ["_extends:protected"]=>
> > array(0) {
> > }
> > }
> > }
> > ["_loadedSection:protected"]=>
> > string(7) "default"
> > ["_extends:protected"]=>
> > array(0) {
> > }
> > }
> >
> > Notice that the Zend_Config produce by the Zend_Config_Xml is missing
> "params"
> > w/c should contain a correct Zend_Config Object like this:
> > $configuration = new Zend_Config(
> > array(
> > 'database' => array(
> > 'adapter' => 'Mysqli',
> > 'params' => array(
> > 'dbname' => 'test',
> > 'username' => 'webuser',
> > 'password' => 'secret',
> > )
> > )
> > )
> > );
> >
> > object(Zend_Config)#32 (6) {
> > ["_allowModifications:protected"]=>
> > bool(false)
> > ["_index:protected"]=>
> > int(0)
> > ["_count:protected"]=>
> > int(1)
> > ["_data:protected"]=>
> > array(1) {
> > ["database"]=>
> > object(Zend_Config)#40 (6) {
> > ["_allowModifications:protected"]=>
> > bool(false)
> > ["_index:protected"]=>
> > int(0)
> > ["_count:protected"]=>
> > int(2)
> > ["_data:protected"]=>
> > array(2) {
> > ["adapter"]=>
> > string(6) "Mysqli"
> > ["params"]=>
> > object(Zend_Config)#43 (6) {
> > ["_allowModifications:protected"]=>
> > bool(false)
> > ["_index:protected"]=>
> > int(0)
> > ["_count:protected"]=>
> > int(3)
> > ["_data:protected"]=>
> > array(3) {
> > ["dbname"]=>
> > string(4) "test"
> > ["username"]=>
> > string(7) "webuser"
> > ["password"]=>
> > string(6) "secret"
> > }
> > ["_loadedSection:protected"]=>
> > NULL
> > ["_extends:protected"]=>
> > array(0) {
> > }
> > }
> > }
> > ["_loadedSection:protected"]=>
> > NULL
> > ["_extends:protected"]=>
> > array(0) {
> > }
> > }
> > }
> > ["_loadedSection:protected"]=>
> > NULL
> > ["_extends:protected"]=>
> > array(0) {
> > }
> > }
> >
> >
> > Thanks,
> > Garri
>
> --
> Matthew Weier O'Phinney
> PHP Developer | [EMAIL PROTECTED]
> Zend - The PHP Company | http://www.zend.com/
>
Hi Matthew,
I have tried your suggestion but still no luck. Here's the part that uses
$this->config.
public function getDb()
{
if (null === $this->_services['db']) {
$config = $this->config->database;
//$this->_services['db'] = Zend_Db::factory($config->type,
$config);
$this->_services['db'] =
Zend_Db::factory($config->database->type, $config->database);
}
return $this->_services['db'];
}
As you can see I have already assigned $this->config->database to $config.
Though I have tried what you have suggest again it's throwing me the same
error.