Wednesday, November 2, 2011

Relationship Type

 class A extends AppModel {  
      var $name = 'A';  
      var $hasOne = array(  
           'E' => array(  
                'className'  => 'E',  
                'conditions'  => '',  
                'dependent'  => true  
           )  
      );  
      var $belongsTo = array(  
           'D' => array(     
                'className'  => 'D',  
                'foreignKey'  => 'd_id'  
           )  
      );   
      var $hasMany = array(  
           'C' => array(  
                'className'   => 'C',  
                'foreignKey'  => 'a_id',  
                'conditions'  =>'',  
                'order'  => '',  
                'limit'    => '',  
                'dependent'=> true  
           )  
      );   
      var $hasAndBelongsToMany = array(  
           'B' =>array(  
                'className' => 'B',  
                'joinTable' => 'as_bs',  
                'foreignKey' => 'a_id',  
                'associationForeignKey' => 'b_id',  
                'unique' => true,  
                'conditions' => '',  
                'fields' => '',  
                'order' => '',  
                'limit' => '',  
                'offset' => '',  
                'finderQuery' => '',  
                'deleteQuery' => '',  
                'insertQuery' => ''  
           )  
      );  
 }  


refer:http://book.cakephp.org/view/1040/Relationship-Types

No comments:

Post a Comment