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,我需要標題。謝了哥們 –