그래서 CakePHP로 양식을 저장하려고합니다. 아주 간단한 형식이지만, 어떤 이유로 INSERT 문이 생성되지 않습니다. 여기 CakePHP 2.0 저장 안함
는 컨트롤러에서 조각입니다 : 데이터베이스 여기<?php
echo $this->Html->script(array(
'dhtmlxCalendar/dhtmlxcalendar.js'
));
echo $this->Html->css(array('dhtmlxCalendar/dhtmlxcalendar.css', 'dhtmlxCalendar/skins/dhtmlxcalendar_dhx_skyblue.css'));
?>
<div style="position:relative;height:380px;">
<?php echo $this->Form->create('Dates'); ?>
<?php echo $this->Form->input('schoolid', array('value' => $schoolid, 'type' => 'hidden')); ?>
<?php echo $this->Form->input('grade', array('options' => array('5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12'))); ?>
<?php echo $this->Form->input('startreg', array('label' => 'Start Registration Date')); ?>
<?php echo $this->Form->input('endreg', array('label' => 'End Registration Date')); ?>
<?php echo $this->Form->input('lottery', array('label' => 'Lottery Date')); ?>
<?php echo $this->Form->end('Save Dates'); ?>
</div>
<?php echo $this->Html->script(array('Schools/add.js')); ?>
된다 : 여기
<?php
class Date extends AppModel {
public $name = 'Date';
}
뷰입니다 : 여기
public function add($sid = null) {
if($this->request->is('post')) {
//The app enters here. debug($this->request->data) confirms the data is there.
if($this->Date->save($this->request->data)) {
//debug($this->Date->save($this->request->data)) confirms CakePHP thinks its saving the data
//however looking at the data, and the MySQL log, an INSERT statement is never attempted.
//The flash and redirect occur as expected.
$this->Session->setFlash('Dates Saved!');
$this->redirect(array('action' => 'school', $sid));
}
}
$this->set('schoolid', $sid);
}
나의 모델이다
CREATE TABLE IF NOT EXISTS `dates` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`schoolid` int(2) NOT NULL,
`grade` int(2) NOT NULL,
`startreg` datetime NOT NULL,
`endreg` datetime NOT NULL,
`lottery` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
왜 이런 일이 발생했는지 또는이 문제를 해결하기 위해 취할 수있는 디버그 단계가 있다면 누구나 알고 있습니다.
무엇을 위해서 var_dump이 배열 $ this-> 요청 -> 데이터를 보여줍니다? –