$dts = new DateTime(AppController::getSetting('event_start'));
$dtf = new DateTime(AppController::getSetting('event_finish'));
//CONTROLLER
...
$weekdays = array(0,1,2,3,4,5,6);
$dates = array();
$today = strtotime(date("Y-m-d", $dts->getTimestamp()));
$end_date = strtotime(date("Y-m-d", $dtf->getTimestamp()));
while($today <= $end_date)
{
$weekday = date("w", $today);
if (in_array($weekday, $weekdays))
{
array_push($dates, date("Y-m-d", $today));
}
$today += 86400;
}
$this->set('dates', $dates);
...
//VIEW
...
echo $this->Form->input('date', array('options'=> $dates));
...
dts 和 dtf 是我从数据库中获取的开始和结束日期...
当我从视图中的下拉框中选择一个日期时,它可以提交,但我在数据库中得到的只是 0000-00-00?
我在这里做错了什么?
编辑
我的数组输出
Debugger::dump($dates);
array(
(int) 0 => '2013-04-01',
(int) 1 => '2013-04-02',
(int) 2 => '2013-04-03',
(int) 3 => '2013-04-04',
(int) 4 => '2013-04-05',
(int) 5 => '2013-04-06',
(int) 6 => '2013-04-07'
)
编辑这就是我的查询的样子
INSERT INTO cake.tickets (first_name, last_name, email, phone, date, quantity) VALUES ('brbt', 'trbb', 'ver@fvef.com', 765657, //THIS IS THE DATE//2, 2) .
好像只能输入key?