RE: [PEAR] DataObject: getLink
| From: | Andy Crain | Date: | Fri, 08 Aug 2003 17:50:03 +0000 |
| Subject: | RE: [PEAR] DataObject: getLink | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-7115@lists.php.net to get a copy of this message | ||
Marco,
This might be a typo, but shouldn't you have
"$tb_A->find();" rather than "$content->find();" and in the next line
"while ($tb_A->fetch)" rather than "while ($content->fetch)"?
Also, check that your links.ini file has an entry like this:
[tb_C]
id_A = tb_A:id_A
id_B = tb_B:id_B
Andy
> Hello
>
> I have 3 tables that build together a m:n relation.
>
> Table tb_A has a filed (integer) called id_A
>
> Table tb_B has a filed (integer) called id_B
>
> Table tb_C has a filed (integer) called id_C and the keys from table
> A (id_A) and table B (id_B)
>
> My (test-) code looks as follows:
>
> $tb_A = new DataObject_A();
> $tb_A->id_A = 5;
>
> $content->find();
> while ($content->fetch()) {
> $c = $tb_A->getLink('id_A', 'tb_c', 'id_A');
>
> $str = "id_A: " .
> $tb_a->id_A .
> " references in tb_C id_B: " .
> $c->id_B .
> "<br>";
>
> echo $str;
> }
>
>
> This code does not work as expected. The return from $tb_A->getLink is
> false.
>
> According to the manual, the while-statement should be:
>
> while ($content->find()) {
> ...
>
> but this results in an endless loop.
>
> Can anybody tell me what I am doing wrong, please. I would also be
glad
> the get tips how to process such a m:n relation effectively by using
> DataObject.
>
> Thanks a lot!
>
> --
> Cheers!
> Marco
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php