Differences

This shows you the differences between the selected revision and the current version of the page.

tutorials:model_relationship_recipes 2010/01/04 18:08 tutorials:model_relationship_recipes 2010/01/04 18:11 current
Line 149: Line 149:
} }
</code> </code>
 +
===== Basic Many To Many ===== ===== Basic Many To Many =====
Line 179: Line 180:
        // Map to sites.         // Map to sites.
        $this->_hasMany('layout2site', array(         $this->_hasMany('layout2site', array(
-            'foreign_class' => 'Vendor_Model_Layout2Site', 
            'foreign_key'  => 'layout_id',             'foreign_key'  => 'layout_id',
        ));         ));
Line 185: Line 185:
        // Sites where this layout is used.         // Sites where this layout is used.
        $this->_hasMany('sites', array(         $this->_hasMany('sites', array(
-            'foreign_class' => 'Vendor_Model_Site', 
            'through'      => 'layout2site',             'through'      => 'layout2site',
            'through_key'  => 'site_id',             'through_key'  => 'site_id',
Line 217: Line 216:
        // Map to layouts.         // Map to layouts.
        $this->_hasMany('layout2site', array(         $this->_hasMany('layout2site', array(
-            'foreign_class' => 'Vendor_Model_Layout2Site',+            'foreign_name' => 'layout2site',
            'foreign_key'  => 'site_id',             'foreign_key'  => 'site_id',
        ));         ));
Line 223: Line 222:
        // Layouts used by this site.         // Layouts used by this site.
        $this->_hasMany('layouts', array(         $this->_hasMany('layouts', array(
-            'foreign_class' => 'Vendor_Model_Layout', 
            'through'      => 'layout2site',             'through'      => 'layout2site',
            'through_key'  => 'layout_id',             'through_key'  => 'layout_id',
Line 262: Line 260:
        $this->_belongsTo('site', array(         $this->_belongsTo('site', array(
-            'foreign_class' => 'Vendor_Model_Site', +            'foreign_key'    => 'site_id',
-            'native_key'    => 'site_id',+
        ));         ));
        $this->_belongsTo('layout', array(         $this->_belongsTo('layout', array(
-            'foreign_class' => 'Vendor_Model_Layout', +            'foreign_key'    => 'layout_id',
-            'native_key'    => 'layout_id',+
        ));         ));
    }     }
 
tutorials/model_relationship_recipes.txt · Last modified: 2010/01/04 18:11 by pmjones