Re: PEAR::Config question
| From: | Jean-Marc FONTAINE | Date: | Fri, 30 May 2003 07:53:02 +0000 |
| Subject: | Re: PEAR::Config question | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5701@lists.php.net to get a copy of this message | ||
Hi Bertrand,
>You are probably not using the class correctly.
That's what I think too :-)
>If you want more help, post some code reproducing the problem so I can
have a look.
Ok here it is :
This part is in a file that is automatically prepended to every script:
require_once('Config.php');
$configuration = new Config;
//$root =&
$configuration->parseConfig("../includes/configuration_{$media}.xml",
'xml');
$root =&
$configuration->parseConfig("../includes/configuration_{$media}.php",
'phparray', array('name' => 'conf'));
$conf = $root->toArray();
$conf = $conf['root']['configuration'];
unset($root);
then I change some value in the $conf array and I use the following function
to save the configuration file. (I do this because I have many forms for
manipulating the configuration values)
function sauver_configuration()
{
global $configuration;
global $conf;
$temp = new Config;
$tableau = array();
$tableau['configuration'] = $conf;
$root =& $temp->parseConfig($tableau, 'phparray');
$configuration->setRoot($root);
return $configuration->writeConfig('testy.xml', 'xml'); // I save to another
file for testing purposes but am I obliged to specify the filename if it is
the same file from which we read the values ?
}
I think this is quite a bad way to use the class but I found no real help in
the exampls and the documentation.
Thanks for you help
Jean-Marc
Bertrand Mansion
Mamasam