Re: Re: Choosing which column to use with DB_DataObject::joinAdd()

From: Date: Wed, 29 Jun 2005 13:18:56 +0000
Subject: Re: Re: Choosing which column to use with DB_DataObject::joinAdd()
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19816@lists.php.net to get a copy of this message
Hi Phil, On Jun 29, 2005, at 5:00 AM, Phil Gyford wrote:
Well, I found a way around the problem, but it's nasty and hacky and I'm sure there must be a better way...? <snip>
        global $_DB_DATAOBJECT;
         if ($direction == 'out') {
                 $friend->from_id = $person_id;
                 $person->joinAdd($friend); // Should join on
friend.to_id=person.id
         } else {
                 $friend->to_id = $person_id;
unset($_DB_DATAOBJECT['LINKS'][$database][$friend->__table]['to_id']); $_DB_DATAOBJECT['LINKS'][$database][$friend->__table]['from_id'] = $person->__table.':id';
                 $person->joinAdd($friend); // Should join on
friend.from_id=person.id
         }
</snip>
how's about:
    global $_DB_DATAOBJECT;
    if ($direction == 'out') {
        $person->joinAdd(array('friend', 'from_id'));
    } else {
        $person->joinAdd(array('friend', 'to_id'));
    }
I ran into a similar problem a few months ago, and I think this resolved it (but wasn't documented so I had to make a lot of use of this list and dig around in the source code). James. -- James Stewart Play: http://james.anthropiccollective.org Work: http://jystewart.net

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