Skip to content

Instantly share code, notes, and snippets.

@rvsjoen
Created December 29, 2013 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvsjoen/8174290 to your computer and use it in GitHub Desktop.
Save rvsjoen/8174290 to your computer and use it in GitHub Desktop.
class Item extends AppModel
{
public $recursive = -1;
public $actsAs = array('Containable');
public $hasMany = array(
'Review' => array(
'ClassName' => 'Review',
'foreignKey' => 'item_id'
)
);
}
class User extends AppModel
{
public $actsAs = array('Containable');
public $hasMany = array(
'Review' => array(
'ClassName' => 'Review',
'foreignKey' => 'user_id'
)
);
}
lass Review extends AppModel
{
public $actsAs = array('Containable');
public $belongsTo = array(
'User' => array(
'ClassName' => 'User',
'foreignKey' => 'user_id',
),
'Item' => array(
'ClassName' => 'Item',
'foreignKey' => 'item_id',
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment