Re: data object getLinks

From: Date: Fri, 30 May 2003 01:04:02 +0000
Subject: Re: data object getLinks
References: 1  Groups: php.pear.general php.pear.general 
Request: Send a blank email to pear-general+get-5697@lists.php.net to get a copy of this message
I've not tried it, but in theory, $object->getLinks() $arr[] = $object->_linkedrow; while($object->_linkedrow->fetch()) { $arr[] = $object->_linkedrow; } should get you the N items... if not, I probably need to look at using the code in joinAdd to return an unfetched element on 1:N relations.. regards Alan Mitchell Perilstein wrote:
Hi all, Hope this doesn't sound too strange. Does getLinks() support MULTIPLE, UNIQUE links to the same table? That is, pointers to different instances. In my case I have a Reservation table which has columns for two trains holding foriegn ids, which indexing a Train table. (This represents a 2:N relation. Since the 2 is fixed by the real world, I saw no point in an M:N table when two columns would do it.) CREATE TABLE tReservation ( tTrain_id_1 smallint(6) NOT NULL default '0', tTrain_id_2 smallint(6) NOT NULL default '0', ... ); CREATE TABLE tTrain ( trainId smallint(6) NOT NULL auto_increment, ... ); I have experimented with something like this in the links table
    [tReservation]
    tTrain_id_1  = tTrain:trainId
    tTrain_id_2  = tTrain:trainId
but it's not reliable. getLinks() is working well in other parts of this same system, but I wonder if I'm abusing it here. Perhaps I need to override getLinks to explicitly do those two loads? Thanks,


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