我遇到了CakePHP的问题
代理模型:agent.php
class Agent extends AppModel{
var $name = 'Agent';
var $belongsTo = array(
'Arrival'=>array(
'className'=>'AirTime',
'foreignKey'=>'arrival_id'
),
'Departure'=>array(
'className'=>'AirTime',
'foreignKey'=>'departure_id'
));
}
通话时间模型:airtime.php
class AirTime extends AppModel{
var $name = 'AirTime';
}
Controller:agentController.php
$condition = array(
'limit'=>20,
'contain'=>array(
'Arrival'=>array(
'fields'=>array('airline_id','flight_num'),
'Airline'=>array('fields'=>'code')
),
'Departure'=>array(
'fields'=>array('airline_id','flight_num'),
'Airline'=>array('fields'=>'code')
)
)
);
$this->Agent = ClassRegistry::init('Agent');
$this->paginate=$condition;
$data = $this->paginate('Agent');
当我运行它时,我收到以下错误:
Warning (512): Model "Agent" is not associated with model "Arrival" [CORE/cake/libs/model/behaviors/containable.php, line 343]
Warning (512): Model "Agent" is not associated with model "Departure" [CORE/cake/libs/model/behaviors/containable.php, line 343]
我不知道如何解决这个问题,并希望得到一些帮助。
答案 0 :(得分:0)
重命名文件
agent.php -> Agent.php
airtime.php -> AirTime.php
agentController.php -> AgentController.php