AddAction.php
$Form = D('Add');
if($Form->create()) {
$result = D('Show')->data($data)->add();
if($result) {
$this->success('添加成功!');
}else{
$this->error('添加错误!');
}
}else{
$this->error($Form->getError());
}AddModel.class.phpclass AddModel extends Model {
// 定义自动验证
protected $_validate = array(
array('imgurl','require','请填写信息,'),
);
// 定义自动完成
protected $_auto = array(
array('showtime','time',1,'function'),
array('ip','get_client_ip',1,'function')
);
} 最佳答案