RE: [PEAR][DB][DataObject] links.ini
| From: | Andy Crain | Date: | Thu, 11 Sep 2003 22:10:18 +0000 |
| Subject: | RE: [PEAR][DB][DataObject] links.ini | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-7754@lists.php.net to get a copy of this message | ||
I don't use getLinks() much, but I think what you want, after calling
getLinks() is to use the related table's key name, not the calling
table's foreign key name, so "$person->_ID->name" instead of
"$person->_affiliationID->name"...but that's not tested and I could be
wrong.
Andy
> -----Original Message-----
> From: Matthias H. Risse [mailto:risse@risse.org]
> Sent: Thursday, September 11, 2003 5:36 PM
> To: Andy Crain; pear-general@lists.php.net
> Subject: re: [PEAR][DB][DataObject] links.ini
>
>
> hi andy, hi all others!
> finally here is my derived code from
> the manpages. what's my problem?
>
> // ################################################################
> // code
> // ################################################################
>
> $person = new DataObjects_Users;
> $person->affiliationID = '1';
>
> /*
> // without links.ini
> // works
> $person->find();
> while ($person->fetch()) {
> // this will look up in the cars table for the id
matching
> the
> person->car value.
>
> $organization = $person-
> >getLink('affiliationID','Organization','ID');
>
> echo "{$person->login} is associated with
> {$organization->name}<br>\n";
>
> echo "<br><br>";
> print_r($organization);
> echo "<br><br>";
>
> }
> */
>
> // with links.ini
> // doesnt work
> $person->find();
> while ($person->fetch()) {
>
> // use the links.ini file to automatically load
> // the car object into $person->_car <<<< EH? well..
> $person->getLinks();
> echo "{$person->login} loves to work at
> {$person->_affiliationID->name}\n<br><br>";
> print_r($person);
> echo "<br><br>";
> }
> ?>
>
>
> // ################################################################
> // mydbname.links.ini
> // ################################################################
>
> [users]
> affiliationID = organization:ID