views:

23

answers:

2

I have two simple tables: Projects and SubProjects which I'd like to print every subproject with the respective project in a table.

So I wrote this:

class Admin_Model_Projects extends Zend_Db_Table_Abstract
{
    protected $_name = 'main_projects';
    protected $_primary = 'mai_id';
    protected $_sequence = true;
    protected $_dependentTables = array('Admin_Model_SubProjects');
    ....

And this:

class Admin_Model_SubProjects extends Zend_Db_Table_Abstract
{
    protected $_name = 'sub_projects';
    protected $_primary = 'sub_id';
    protected $_sequence = true;
    protected $_referenceMap = array(
        'columns' => 'mai_id',
        'refTableClass' => 'Admin_Model_Projects',
        'refColumns' => 'mai_id'
    );
    .....

I'd like to know why do I get No reference from table Admin_Model_SubProjects to table Admin_Model_Projects when I type <?php echo $entry->findParentRow('Admin_Model_Projects'); ?>

A: 

You should define $_referenceMap and $_dependentTables in all of the related table-classes. It will look close-to mirrored when you're done.

chelmertz
+1  A: 

Looks like you're missing name of the rule in your referenceMap definition.
It should be

protected $_referenceMap = array(
    'Project' => array(
        'columns' => 'mai_id',
        'refTableClass' => 'Admin_Model_Projects',
        'refColumns' => 'mai_id'
    )
);
Vika