re:DB_DataObject::joinAdd issue

From: Date: Sat, 18 Jan 2003 03:03:32 +0000
Subject: re:DB_DataObject::joinAdd issue
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3334@lists.php.net to get a copy of this message
had a quick look at this, you are probably best adding $run->selectAdd('tTrain.id as tTrain_id, tSchedRun.id as tSchedRun_id'); I'm reluctant to add to much magic behind the scenes here, as doing join is confusing enough without adding to much unexpected behavour.. Regards Alan I don't know if this is intended behavior of DB_DataObject::joinAdd() or not, but I have a workaround if someone needs it. I have two tables, both with integer primary keys named "id" like this: create table tTrain (
   id                        smallint auto_increment not null,
... ); create table tSchedRun (
   id                        smallint auto_increment not null,
... ); My code does this: $train = new DataObjects_TTrain; $run = new DataObjects_TSchedRun; $run->some_fields = ...my_run_critera...; $train->joinAdd($run); $train->find(); while ($train->fetch()) { ... } This did one unexpected thing: for all the Train objects retrieved, each had its "id" field set to the SchedRun object found. The Train objects were intact otherwise. My workaround was to rename both id fields to be unique across those two objects, in violation of my field naming conventions. When that was done, the Train ids came out untouched as hoped. Otherwise, I'm finding joinAdd() very useful. -- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

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