我想在数据插入时自动将当前的日期和时间写入数据段ctime中。
以下是代码,我不知道那个地方出错误?
NewsModel.class.php
protected $_auto = array(
array('ctime','now',1,'function'),
);
//now为mysql的函数now()
public function AddNews($ti
$data=array('ti
$flag = $this->data($data)->add();
return $flag;
}
NewsAction.class.php
public function addnews(){
$news=D('News');
$flag = $news->AddNews($ti
if($flag>=1){
$this->success('数据添加成功',"$this-
>CurrentActionPath/inputnews");
}
else{
$this->error('数据添加失败,请重新输入!');
}
}
运行结果是自动完成的内容无法实现,其他数据段添加成功?????
最佳答案