Issues

ZF-7861: Using namespaced models in relationships within Zend_Db_Table_Abstract

Issue Type: Improvement Created: 2009-09-16T07:48:34.000+0000 Last Updated: 2012-11-20T21:37:40.000+0000 Status: Open Fix version(s): Reporter: Adam Charnock (adamcharnock) Assignee: None Tags: - Zend_Db_Table

Related issues: Attachments:

Description

With regards to defining relationships in subclasses of Zend_Db_Table_Abstract: http://framework.zend.com/manual/en/…

It seems that namespaced models are not supported. So I want to do this:

<pre class="highlight">
$questionModel = new Blah_Model_Question();
$questionRow = $questionModel->find(5)->current();
$section = $questionRow->findParentSection();

But I have to do this:

<pre class="highlight">
$questionModel = new Blah_Model_Question();
$questionRow = $questionModel->find(5)->current();
$section = $questionRow->findParentBlah_Model_Section(); //Not looking good!

My model looks like this:

<pre class="highlight">
class Dlapiper_Model_Question extends Dlapiper_Model_Abstract {
    
    protected $_name = 'questions';
    protected $_primary = 'question_id';
    
    protected $_referenceMap = array(
        'Section' => array(
            'columns' => 'section_id',
            'refTableClass' => 'Dlapiper_Model_Section',
            'refColumns' => 'section_id'
        )
    );
.....
}

I cannot see a simple workaround in this situation, so it would be great to have support for this.

Comments

Posted by Christoph Roensch (croensch) on 2010-06-01T02:10:43.000+0000

While the ->find*() functions are syntactic Sugar they not provide any namespacing or aliasing. Therefor it's pretty useless in bigger Projects.

I usually create Table and Row Classes and write simple proxy functions in the Row Class.

<pre class="highlight">
/**
 * @return SectionRow
 */
public function getSection()
{
  return $this->findParentRow('namespace_SectionTable');
}

Workaround indeed.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts