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

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

Reply via email to