开发者

CakePHP Model Associations

开发者 https://www.devze.com 2023-04-07 16:36 出处:网络
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:

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

精彩评论

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

关注公众号