0
我的add.ctp表单返回“错误:SQLSTATE [HY000]:一般错误:1364字段'标题'没有默认值”。我不知道为什么,一切都似乎写得很对。我输入标题,但不会将它保存到数据库中。CakePHP - 错误:SQLSTATE [HY000]:一般错误:1364字段'标题'
AlbumsController.php
class AlbumsController extends AppController {
public function add() {
if($this->request->is('post')) {
$this->Album->create();
$this->Album->save('$this->request->data');
}
}
}
add.ctp
<?php
echo $this->Form->create('Album', array('type' => 'file'));
echo "<br>";
echo $this->Form->input('created', array('label' => '', 'separator' => ' ', 'timeFormat' => '24'));
echo "<br>";
echo $this->Form->input('title', array('label' => 'Naslov albuma<br>'));
echo "<br><br>";
echo $this->Form->end('Create album');
?>
哦,谢谢..愚蠢的我。 –
是的,我不需要它null,我需要标题。谢了哥们 –