DB_DataObject::joinAdd issue
| From: | mitchell perilstein | Date: | Thu, 16 Jan 2003 23:19:03 +0000 |
| Subject: | DB_DataObject::joinAdd issue | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-3330@lists.php.net to get a copy of this message | ||
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.
--
Mitchell Perilstein
mitch at enetis dot net
www.enetis.net/~mitch