开发者

CakePHP Containable: Model "Comp" is not associated with model "Comp"

I am trying to do a fairly simple CakePHP find using the Containable behavior:

$comp = $this->Comp->find('first', array(
    'conditions' => array('Comp.id' => $id),
    'contain' => array(
        'Comp.id' => array(
            'fields' => array('Comp.id'),
        ),
        'Slot' => array(
            'fields' => array(
                'Slot.start_time',
                'Slot.end_time'
            )
        ),
        'Team'
    )
));

...but upon execution a warning is shown:

Warning (512): Model "Comp" is not associated with model "Comp" [CORE/cake/libs/model/behaviors/containable.php, l开发者_Go百科ine 363]

The start of my Comp model is as follows:

var $name = 'Comp';
var $hasMany = array('Team', 'Round', 'Match');
var $belongsTo = array('Generation');
var $hasAndBelongsToMany = array('Slot');
var $actsAs = array('Containable');

I am using CakePHP 1.3.6

Any ideas what may be causing this?


$comp = $this->Comp->find('first', array(
    'conditions' => array('Comp.id' => $id),
    'fields'     => array('Comp.id'),
    'contain'    => array(
        'Slot'       => array(
            'fields'     => array(
                'Slot.start_time',
                'Slot.end_time'
            )
        ),
        'Team'
    )
));

You told it to contain the related Comp.id, which means the model Comp related to Comp, which doesn't exist. You probably meant to simply set the fields option of the Comp model itself?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜