我有这样一个数组:
日期的格式无效
$holiday = array(array('h_date' => $new_year, 'd_name' => 'New Year'),
array('h_date' => $memorial_day, 'd_name' => 'Memorial Day')
foreach($holiday as $holidays){
$date = $holidays["h_date"];
$name = $holidays["d_name"]
当我保存在MySQL数据库
$model = new Holiday();
$model->holiday_date = $date;
$model->display_name = $name;
$model->save();
当我写
$model->save(false);
值保存成功,但看到比错误验证错误时没有 “假” 数据不保存
:
Array ([holiday_date] => Array ([0] => The format of Holiday Date is invalid.))
我们使用
protected function beforeSave(){
if(parent::beforeSave()){
$this->holiday_date=date('Y-m-d',strtotime($this->holiday_date));
return TRUE;
}
return false;
}
您节省的领域是char更改为date – Vineet1982 2013-03-05 05:45:35
先生,请详细说明。 – Rishabh 2013-03-05 05:53:09
在mysql中将字段类型从char转换为日期 – Vineet1982 2013-03-05 05:53:52