开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜