title: Zend Relationship - Two column referencing single field in other table
body: <p>I have two tables with structure as mentioned below:</p>
  
  <pre><code> CREATE TABLE `up_offer` (
    `up_offer_id` int(11) NOT NULL AUTO_INCREMENT,
    `from_subscription_id` int(11) NOT NULL,
    `to_subscription_id` int(11) NOT NULL,
    PRIMARY KEY (`up_offer_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  CREATE TABLE `subscription` (
    `subscription_id` int(11) NOT NULL AUTO_INCREMENT,
    `name` varchar(1000) NOT NULL,
    `code` varchar(45) NOT NULL,
    `price` decimal(6,2) NOT NULL,
    `billing_cycle` int(11) NOT NULL,
    `desc` varchar(2000) DEFAULT NULL,
    `start_date` date NOT NULL,
    `end_date` date NOT NULL,
    `emaillist_id` int(11) NOT NULL,
    `old_created_date` datetime NOT NULL,
    `old_last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `created_on` datetime NOT NULL,
    `last_updated_on` datetime NOT NULL,
    `is_active` bit(1) NOT NULL DEFAULT b'1',
    PRIMARY KEY (`subscription_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p>The dbTable Class am using for both the tables is as follows:</p>
  
  <pre><code>class Admin_Model_DbTable_Subscription extends Zend_Db_Table_Abstract
  {
      protected $_name = 'subscription';
      protected $_primary = 'subscription_id';
  
      protected $_dependentTables = 'Admin_Model_DbTable_UpOffer';
  
      protected $_referenceMap = array(
          'UpOffer' =&gt; array(
              'columns'       =&gt; array('subscription_id'),
              'refTableClass' =&gt; 'Admin_Model_DbTable_UpOffer',
              'refColumns'    =&gt; array('from_subscription_id','to_subscription_id'),
          ),
      );
  
  }
  
  class Admin_Model_DbTable_UpOffer extends Zend_Db_Table_Abstract{
      protected $_name = 'up_offer';
  
      protected $_dependentTables = 'Admin_Model_DbTable_Offer'; 
  
      protected $_referenceMap = array(
          'Offer'=&gt;array(
              'columns'           =&gt; 'up_offer_id',
              'refTableClass'     =&gt; 'Admin_Model_DbTable_Offer',
              'refColumns'        =&gt; 'up_offer_id'
          )
      );
  }
  </code></pre>
  
  <p>I want to get the dependent data from the 'Zend_Db_Table_Row Object':
  the code am writing is:</p>
  
  <p><code>$upOfferData-&gt;toArray()</code> gives the fields:</p>
  
  <pre><code>Array
  (
      [up_offer_id] =&gt; 1
      [from_subscription_id] =&gt; 10
      [to_subscription_id] =&gt; 9
  )
  </code></pre>
  
  <p>And <code>$upOfferData-&gt;findDependentRowset('Admin_Model_DbTable_Subscription');</code> gives output as follows:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [subscription_id] =&gt; 10
              [name] =&gt; 001
              [code] =&gt; 010
              [price] =&gt; 10.00
              [billing_cycle] =&gt; 1
              [desc] =&gt; Test
              [start_date] =&gt; 2012-04-21
              [end_date] =&gt; 2012-05-20
              [emaillist_id] =&gt; 0
              [old_created_date] =&gt; 0000-00-00 00:00:00
              [old_last_updated] =&gt; 2012-04-20 15:29:57
              [created_on] =&gt; 2012-04-20 09:59:56
              [last_updated_on] =&gt; 2012-04-20 01:31:44
              [is_active] =&gt; 1
          )
  
  )
  </code></pre>
  
  <p>What about the to_subscription_id?
  How do i correctly map the DbTable Classes and what is the correct way of obtaining the desired out?
  The desired should be something like:</p>
  
  <pre><code>Array
      (
          [0] =&gt; Array
              (
                  [subscription_id] =&gt; 10
                  [name] =&gt; 001
                  [code] =&gt; 010
                  [price] =&gt; 10.00
                  [billing_cycle] =&gt; 1
                  [desc] =&gt; Test
                  [start_date] =&gt; 2012-04-21
                  [end_date] =&gt; 2012-05-20
                  [emaillist_id] =&gt; 0
                  [old_created_date] =&gt; 0000-00-00 00:00:00
                  [old_last_updated] =&gt; 2012-04-20 15:29:57
                  [created_on] =&gt; 2012-04-20 09:59:56
                  [last_updated_on] =&gt; 2012-04-20 01:31:44
                  [is_active] =&gt; 1
              )
          [1] =&gt; Array
              (
                  [subscription_id] =&gt; 9
                  [name] =&gt; 002
                  [code] =&gt; 011
                  [price] =&gt; 50.00
                  [billing_cycle] =&gt; 2
                  [desc] =&gt; Test
                  [start_date] =&gt; 2012-04-21
                  [end_date] =&gt; 2012-05-20
                  [emaillist_id] =&gt; 0
                  [old_created_date] =&gt; 0000-00-00 00:00:00
                  [old_last_updated] =&gt; 2012-04-20 15:29:57
                  [created_on] =&gt; 2012-04-20 09:59:56
                  [last_updated_on] =&gt; 2012-04-20 01:31:44
                  [is_active] =&gt; 1
              )
      )
  </code></pre>