CakePHP Containable:模型“Comp”不与模型“Comp”相关联。
我正在尝试使用 Containable 行为进行相当简单的 CakePHP 查找:
$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'
)
));
...但在执行时会显示警告:
警告 (512):模型“Comp”不是 与型号“Comp”相关 [CORE/cake/libs/model/behaviors/containable.php, 第363行]
我的 Comp 模型的开头如下:
var $name = 'Comp';
var $hasMany = array('Team', 'Round', 'Match');
var $belongsTo = array('Generation');
var $hasAndBelongsToMany = array('Slot');
var $actsAs = array('Containable');
我正在使用 CakePHP 1.3.6
有什么想法可能导致此情况吗?
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,
line 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您告诉它
包含
相关的Comp.id
,这意味着模型Comp
与Comp
相关,这并不不存在。您可能只想简单地设置Comp
模型本身的fields
选项?You told it to
contain
the relatedComp.id
, which means the modelComp
related toComp
, which doesn't exist. You probably meant to simply set thefields
option of theComp
model itself?