ZF-7861: Using namespaced models in relationships within Zend_Db_Table_Abstract
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:
$questionModel = new Blah_Model_Question();
$questionRow = $questionModel->find(5)->current();
$section = $questionRow->findParentSection();
But I have to do this:
$questionModel = new Blah_Model_Question();
$questionRow = $questionModel->find(5)->current();
$section = $questionRow->findParentBlah_Model_Section(); //Not looking good!
My model looks like this:
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.
Workaround indeed.