Issue Type: Bug Created: 2008-07-21T19:01:23.000+0000 Last Updated: 2010-02-19T13:14:41.000+0000 Status: Resolved Fix version(s): - 1.10.2 (24/Feb/10)
Reporter: Metagamer (metagaming) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db_Table
Related issues: - ZF-6232
Attachments:
I stumbled across this inconsistency while following some of the examples of the framework documentation about Zend_Db_Table relationships
Sample tables:
<pre class="highlight">
CREATE TABLE owners (
id int(10) unsigned NOT NULL auto_increment PRIMARY_KEY,
name varchar(64) NOT NULL,
);
CREATE TABLE cars (
id int(10) unsigned NOT NULL auto_increment PRIMARY_KEY,
model varchar(64) NOT NULL,
);
CREATE TABLE owner_car (
owner_id int(10) unsigned NOT NULL,
car_id int(10) unsigned NOT NULL,
mileage int(10) unsigned NOT NULL,
);
Then the referenceMap for owner_car:
<pre class="highlight">
protected $_referenceMap = array(
'Owner' => array(
'columns' => array('owner_id'),
'refTableClass' => 'owners',
'refColumns' => array('id'),
),
'Car' => array(
'columns' => array('car_id'),
'refTableClass' => 'cars',
'refColumns' => array('id'),
)
);
Then when you use the findManyToManyRowset() from a Zend_Db_Table_Row object:
<pre class="highlight">
$ownerTable = new owners();
$ownerRecord = $ownerTable->fetchRow('id = 1');
$manyToManyRecords = $ownerRecord->findManyToManyRowset('cars', 'owner_car');
The resulting rows in the rowset contain the following columns:
owner_id, car_id, mileage, id, model,
the readOnly value of the row object will be false and the tableClass will be set to cars any subsequent save() will fail with an exception since not all returned columns are present in the cars table.
A variety of solutions are possible depending on the intended use cases but it does need some attention
Posted by Michael Rehbein (tech13) on 2009-11-24T11:21:34.000+0000
Wouldn't
<pre class="highlight">
$select->from(array('i' => $interName), array(), $interSchema)
->joinInner(array('m' => $matchName), $joinCond, Zend_Db_Select::SQL_WILDCARD, $matchSchema)
->setIntegrityCheck(false);
in place of
<pre class="highlight">
$select->from(array('i' => $interName), Zend_Db_Select::SQL_WILDCARD, $interSchema)
->joinInner(array('m' => $matchName), $joinCond, Zend_Db_Select::SQL_WILDCARD, $matchSchema)
->setIntegrityCheck(false);
work, so that the join table's columns are ignored.
Posted by Ralph Schindler (ralph) on 2010-02-19T13:14:41.000+0000
Fixed in trunk 21100 and in release branch 1.10 in 21102