RE: [PEAR] DataObject DB connection failing
| From: | LIMBOURG Arnaud | Date: | Wed, 11 Dec 2002 13:59:16 +0000 |
| Subject: | RE: [PEAR] DataObject DB connection failing | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-2942@lists.php.net to get a copy of this message | ||
Hello,
You need to initialise the config related stuff before using any instance of
a dataobject class. DataObject needs this to be done to have the dsn and
related stuff so that it can connect to the database.
$options = &PEAR::getStaticProperty('DB_DataObject','options');
DB_DataObject::debugLevel(5);
$config = parse_ini_file('redbox_databases.ini', TRUE);
var_dump($config);
$options = $config['DB_DataObject'];
$person = new DataObjects_Person;
$person->get(12);
Should work.
If not come back here ;))
Arnaud.
> Hi all,
>
> Just found this newsgroup and hope that I can get some clues on using
> PEAR
> stuff.... it's the DataObject I'm having issues with.
>
> I've created all the extended classes based on my database
> tables. The
> problem is actually doing the connection when I call a method such as
> find()
> or get().
>
> I just get the error message "DB Error: not found". The manual was a
> little
> misleading/non-descriptive on how you actually go about using the
> DataObjects from any scripts/private classes.
>
> The manual mentions calling:-
>
> $options =
> &PEAR::getStaticProperty('DB_DataObject','options');
> DB_DataObject::debugLevel(5);
> $config = parse_ini_file('redbox_databases.ini', TRUE);
> var_dump($config);
> $options = $config['DB_DataObject'];
>
> Where should this be called? My code that creates instances of
> DataObjects
> is, itself, within classes so where should I call this initialisation
> code?
> What happens to the $options variable that the init code
> finishes with?
> Does this need to be global if I am calling extended
> DataObject classes
> from
> within my own class methods?
>
> The manual isn't great for getting people started, I think. Could
> anybdy
> explain how things fit together?
>
> Regards,
>
>
>
> --
> Mike Carter [web developer]
> tel: 01925 758229 // fax: 01925 758023 // web: www.koa.uk.com
>
> This message is confidential.
> Unless you are the named addressee or their delegated
> representative you
> may not use, disclose, or copy the contents of the e-mail. If you are
> not the named addressee please notify the sender immediately
> and delete
> the material from your computer. Any views or opinions
> contained in this
> e-mail are solely those of the author unless expressly stated
> otherwise
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>