全部博文(89)
分类:
2008-10-23 09:41:31
class User extends AppModel {
var $name = 'User';
var $hasOne=array('Profile');
}
?>
class User extends AppModel {
var $name = 'User';
var $hasOne = array(
'Profile' => array('className' => 'Profile',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
?>
class Profile extends AppModel {
var $name = 'Profile';
var $belongsTo = array( 'User' );
}
?>
class Profile extends AppModel {
var $name = 'Profile';
var $belongsTo = array(
'User' => array('className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
?>
class User extends AppModel {
var $name = 'User';
var $hasOne = array('Profile');
var $hasMany = array('Post');
}
?>
var $hasMany = array(
'Post' => array('className' => 'Post',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
class Post extends AppModel {
var $name = 'Post';
var $belongsTo = array('User');
var $hasMany = array('Comment');
}
?>
class Comment extends AppModel {
var $name = 'Comment';
var $belongsTo = array('Post');
}
?>
class Post extends AppModel {
var $name = 'Post';
var $belongsTo = array('User');
var $hasMany = array('Comment');
var $hasAndBelongsToMany = array('Tag');
}
?>
var $hasAndBelongsToMany = array(
'Tag' => array('className' => 'Tag',
'joinTable' => 'posts_tags',
'foreignKey' => 'post_id',
'associationForeignKey' => 'tag_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
class Tag extends AppModel {
var $name = 'Tag';
var $hasAndBelongsToMany = array('Post' );
}