As the example in the manual of Zend_DB_Table_Relationships

<?php

class Accounts extends Zend_Db_Table_Abstract
{
   protected $_name            = 'accounts';
   protected $_primary         = array('account_id');
   protected $_dependentTables = array('Bugs');
}

class Products extends Zend_Db_Table_Abstract
{
   protected $_name            = 'products';
   protected $_primary         = array('product_id');
   protected $_dependentTables = array('Bugs');
}

class Bugs extends Zend_Db_Table_Abstract
{
   protected $_name            = 'bugs';
   protected $_referenceMap    = array(
       'Reporter' => array(
           'columns'           => 'reported_by',
           'refTableClass'     => 'Accounts',
           'refColumns'        => 'account_id'
       ),
       'Engineer' => array(
           'columns'           => 'assigned_to',
           'refTableClass'     => 'Accounts',
           'refColumns'        => 'account_id'
       ),
       'Verifier' => array(
           'columns'           => array('verified_by'),
           'refTableClass'     => 'Accounts',
           'refColumns'        => array('account_id')
       ),
       'Product' => array(
           'columns'           => array('product_id'),
           'refTableClass'     => 'Products',
           'refColumns'        => array('product_id')
       )
   );
}

?>

If the primary key of accounts table is id,and the table products or/and
bugs have the same primary key as the table accounts,id.

Now,the code above should change as following

<?php

class Accounts extends Zend_Db_Table_Abstract
{
   protected $_name            = 'accounts';
   protected $_primary         = array('id');
   protected $_dependentTables = array('Bugs');
}

class Products extends Zend_Db_Table_Abstract
{
   protected $_name            = 'products';
   protected $_primary         = array('id');
   protected $_dependentTables = array('Bugs');
}

class Bugs extends Zend_Db_Table_Abstract
{
   protected $_name            = 'bugs';
   protected $_referenceMap    = array(
       'Reporter' => array(
           'columns'           => 'reported_by',
           'refTableClass'     => 'Accounts',
           'refColumns'        => 'id'
       ),
       'Engineer' => array(
           'columns'           => 'assigned_to',
           'refTableClass'     => 'Accounts',
           'refColumns'        => 'id'
       ),
       'Verifier' => array(
           'columns'           => array('verified_by'),
           'refTableClass'     => 'Accounts',
           'refColumns'        => array('id')
       ),
       'Product' => array(
           'columns'           => array('product_id'),
           'refTableClass'     => 'Products',
           'refColumns'        => array('id')
       )
   );
}

?>

And then invoke the findManyToManyRowset method introduce errors.
sorry for my bad english.

Regards,
Jacky


2007/5/16, Bill Karwin <[EMAIL PROTECTED]>:

 Can you show the complete declaration of your $_referenceMap array?  I'm
having difficulty following your description.

Regards,
Bill Karwin

 ------------------------------
*From:* Jacky Chen [mailto:[EMAIL PROTECTED]
*Sent:* Tuesday, May 15, 2007 1:22 AM
*To:* [email protected]
*Subject:* [fw-general] is it a bug?


 Hi list,
In Zend_Db_Table Relationships,if there are two or more tables with the
same primary key in the table _referenceMap,exception would be throw.Idon't 
know if it is a bug.

Regards
Jacky


Reply via email to