DataObject and links.ini question

From: Date: Sun, 07 Mar 2004 15:51:07 +0000
Subject: DataObject and links.ini question
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11144@lists.php.net to get a copy of this message
Hi I have some troubles using getLinks with DataObject. I have two (example-) tables: table_A: | Field | Type | Null | Key | +---------+------------------+------+-----+ | A_ID | int(10) unsigned | | PRI | | A_Value | int(5) | | | table_B: | Field | Type | Null | Key | +---------+------------------+------+-----+ | B_ID | int(10) unsigned | | PRI | | A_ID | int(10) unsigned | | FK | | B_Value | int(5) | | | I set up my database.links.ini (database replaced with real-name): [table_A] A_ID = table_B:A_ID Now, let's say I want to link table_A and table_B with the restriction on table_A's A_value(s) as described in DataObject's manual: <?PHP require_once 'Config_DAO.php'; require_once 'Table_A.php'; $tA = new DAO_table_A; $tA->whereAdd('A_Value > 14'); $tA->whereAdd('A_Value < 27'); $tA->find(); while ($tA->fetch()) { $tA->getLinks(); $str = 'table_A_Value = ' . $tA->A_Value . ' has corresponding value in table_B_Value = ' . $tA->_table_B->B_Value . '<br>'; echo $str; } ?> The output of this test-script is: table_A_Value = 15 has corresponding value in table_B_Value = table_A_Value = 16 has corresponding value in table_B_Value = table_A_Value = 17 has corresponding value in table_B_Value = table_A_Value = 18 has corresponding value in table_B_Value = table_A_Value = 19 has corresponding value in table_B_Value = table_A_Value = 20 has corresponding value in table_B_Value = table_A_Value = 21 has corresponding value in table_B_Value = table_A_Value = 22 has corresponding value in table_B_Value = table_A_Value = 23 has corresponding value in table_B_Value = table_A_Value = 24 has corresponding value in table_B_Value = table_A_Value = 25 has corresponding value in table_B_Value = table_A_Value = 26 has corresponding value in table_B_Value = That's not what I expected... :-( When I change the statement '$tA->_table_B->B_Value' to '$tA->_A_ID->B_Value' the output is fine. I am a bit confused if I did something wrong because it does not behave as described in the manual, or if there is a typo in the manual. Can someone explain me the syntax/semantic of the correct usage? Any tips, comments and suggestions are highly appreciated since I wanna go further to use joins and I want to be sure that my setup is correct. Thanks in advance! -- Regards Marco

« previous php.pear.general (#11144) next »