Ralph,
Doing it that way would require me to instantiate the
Model_DbTable_ISPPartnersAux() class and that is not how I have it
setup.
Theoretically I should be able to instantiate the Partner model and
say now find all rowsets that are in the dependent table based on the
common id. I fixed a few things in the code so here is what I have now.
I did some debugging by adding echo $select->__toString() in my Zend/
Db/Table/Abstract.php fetchRow method and found that the sql query is
just this.
SELECT `isp_partners`.* FROM `isp_partners`
<?php
class KeywordsController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->view->headTitle('Keyword Management', 'APPEND');
$partners = new Model_DbTable_ISPPartners();
$partners_aux = new Model_DbTable_ISPPartnersAux();
$partner = $partners->fetchRow("code = 'red'");
// THIS WORKS FINE WHEN NOT COMMENTED
//$results = $partner-
>findManyToManyRowset('Model_DbTable_ISPKeywords',
'Model_DbTable_ISPWebsites');
// THIS DOES NOT SEEM TO GET HIT OR SOMETHING.
$aux_data = $partner-
>findDependentRowset('Model_DbTable_ISPPartnersAux', 'PartnersAux');
//echo '<pre>'.print_r($results, true).'</pre>'; exit;
$this->view->results = $results;
}
}
<?php
/**
* ISPPartners
*
* @author jcrawford
* @version
*/
class Model_DbTable_ISPPartners extends Zend_Db_Table_Abstract {
/**
* The default table name
*/
protected $_name = 'isp_partners';
protected $_primary = array('isp_id');
protected $_dependentTables = array('Model_DbTable_ISPPartnersAux');
protected $_referenceMap = array(
'PartnersAux' => array(
'columns' => array('isp_id'),
'refTableClass' =>
'Model_DbTable_ISPPartnersAux',
'refColumns' => array('isp_id')
)
);
}
<?php
class Model_DbTable_ISPPartnersAux extends Zend_Db_Table_Abstract
{
/**
* The default table name
*/
protected $_name = 'isp_partners';
protected $_primary = array('isp_id');
protected $_referenceMap = array(
'Partners' => array(
'columns' => array('isp_id'),
'refTableClass' =>
'Model_DbTable_ISPPartners',
'refColumns' => array('isp_id')
)
);
}
On Jul 6, 2009, at 1:19 PM, Ralph Schindler wrote:
In situations where I have auxiliary and/or errata tables (basically
a 1-1 relationship), I would look into peering to those rows via the
findParentRow($parentTable) method rather than finding as a
DependentRowset.
http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.fetching.parent
It is modeled effectively the same way, but you are using a
different approach for finding the actual Row.
Let me know if that helps!
-ralph
Now I have it working for the websites and keywords but cannot get
the isp_partners_aux to work. The issue seems to be that when I do
the findDependantRowset it does not get any data from the
isp_partners_aux table, rather it only contains the data from the
isp_partners table. There is only 1 row in each table that will
match. The aux table is just an external table that holds data
about isp_partners such as the username, etc. Below is my
controller followed by my model classes and then the output.