我是新蛋糕,我正在努力学习它的哲学。所以我想创建一个表格"电影"如下所示,我的数据库接受movie_id,标题,年份和描述。当我运行代码时,它会尝试存储"数组"作为年份输入。这是我得到的错误=> movie_id
,title
,year
,description
)VALUES(NULL,&#39; Movie1&#39;,数组,&#39;某些文字&#39;)< / p>
观点:
<?php echo $this->Form->create('Movie'); ?>
<?php echo __('Add Movie'); ?>
<?php
echo $this->Form->hidden('movie_id');
echo $this->Form->input('title');
echo $this->Form->input('year', array(
'type'=>'date',
'dateFormat'=>'Y',
'minYear'=>'1990',
'maxYear'=>date('Y'),
));
echo $this->Form->input('description');
?>
<?php echo $this->Form->end(__('Submit'));
?>
控制器:
public function add() {
if ($this->request->is('post')) {
$this->Movie->create();
if ($this->Movie->save($this->request->data)) {
$this->Session->setFlash(__('The movie has been created'));
$this->redirect (array('action'=>'index'));
}
else {
$this->Session->setFlash(__('The movie could not be created. Please, try again.'));
}
}
}
正如我所说,我是新蛋糕,所以如果这个问题听起来很愚蠢我会道歉,请给出你的解决方案。感谢