GuestbookModel.class.php 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * 洛阳赤炎鹰网络科技有限公司
  4. * https://www.cyyvip.com
  5. * Copyright (c) 2022 赤店商城 All rights reserved.
  6. */
  7. namespace Common\Model;
  8. use Common\Model\CommonModel;
  9. class GuestbookModel extends CommonModel{
  10. //自动验证
  11. protected $_validate = array(
  12. //array(验证字段,验证规则,错误提示,验证条件,附加规则,验证时间)
  13. array('full_name', 'require', '姓名不能为空!', 1, 'regex', CommonModel:: MODEL_BOTH ),
  14. array('email', 'require', '邮箱不能为空!', 1, 'regex', CommonModel:: MODEL_BOTH ),
  15. array('msg', 'require', '留言不能为空!', 1, 'regex', CommonModel:: MODEL_BOTH ),
  16. array('email','email','邮箱格式不正确!',0,'',CommonModel:: MODEL_BOTH ),
  17. );
  18. protected $_auto = array (
  19. array('createtime','mDate',1,'callback'), // 对msg字段在新增的时候回调htmlspecialchars方法
  20. );
  21. function mDate(){
  22. return date("Y-m-d H:i:s");
  23. }
  24. protected function _before_write(&$data) {
  25. parent::_before_write($data);
  26. }
  27. }