CakePHP Model Associations
Here's the deal, i h开发者_运维百科ave 2 models: Rus and Audios. I want to use records from Audios in Rus controller, so i go and type in associations like this:
<?
class Rus extends AppModel
{
var $name = 'Ru';
var $hasMany = 'Audio';
}
?>
and
<?
class Audios extends AppModel
{
var $name = 'Audio';
var $belongsTo = 'Ru';
}
?>
when i use scaffol feature nothing works. help please.
Try the following.
ru.php:
<?
class Ru extends AppModel
{
var $name = 'Ru';
var $hasMany = 'Audio';
}
?>
audio.php
<?
class Audio extends AppModel
{
var $name = 'Audio';
var $belongsTo = 'Ru';
}
?>
Your model names should be singular.
精彩评论