I'm reading Rob Allens Zend Framework in Action book and he has examples for Many-to-Many, and in the below case a 1-to-Many relationship.
But he never showed any examples on how to do a 1-to-1 relationship. Can somebody teach me how it should be done?
1-to-Many example
PHP Code:class Books extends Zend_Db_Table_Abstract
{
protected $_name = 'books';
protected $_dependentTables = array('Reviews');
}
class Reviews extends Zend_Db_Table_Abstract
{
protected $_name = 'reviews';
protected $_referenceMap = array(
'Book' => array(
'columns' => array('book_id'),
'refTableClass' => 'Books',
'refColumns' => array('id')
)
);
}
Let's say that I want to connect Class Books with Class Genre, a 1-to-1 relationship. How do I determine which of the tables should use either one of these? Which table is depending on the other table?
- $_dependentTables
- $_referenceMap
Do I still define their relationship exactly like how the 1-to-Many example is done?







Bookmarks