博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP,ZF2
阅读量:7082 次
发布时间:2019-06-28

本文共 5366 字,大约阅读时间需要 17 分钟。

hot3.png

数据库表基类:

getArrayCopy();              foreach ($properties as $key => $value) {
           if($key != 'inputFilter') {
               $this->$key = (!empty($data[$key])) ? $data[$key] : null;            }        }                    }        public function getArrayCopy(){
      return get_object_vars($this);    }        public function getInputFilter() {
   }    public function setInputFilter(InputFilterInterface $inputFilter) {
       throw new \Exception('Not used');    } }

实现类:

inputFilter) {
           $this->inputFilter = new InputFilter();            $this->inputFilter->add([                'name'=>'employeeId',                'required'=>true,                'filters'=>[                    ['name'=>'StringTrim'],                ],                'validators'=>[                    ['name'=>'NotEmpty',                        'options'=>[                            'message'=>[                                '\Zend\Validator\NotEmpty::IS_EMPTY'=>'员工号不能为空',                            ],                        ],                    ],                ]            ]);            $this->inputFilter->add([                'name'=>'attendId',                'required'=>true,                'filters'=>[                    ['name'=>'StringTrim'],                ],                'validators'=>[                    ['name'=>'NotEmpty',                        'options'=>[                            'message'=>[                                '\Zend\Validator\NotEmpty::IS_EMPTY'=>'考勤号不能为空',                            ],                        ],                    ],                    ['name'=>'Digits',                        'options'=>[                            'message'=>[                                '\Zend\Validator\Digits::NOT_DIGITS'=>'考勤号只能为数字'                            ]                        ]                    ]                ]            ]);            $this->inputFilter->add([                'name'=>'identify',                'required'=>true,                'filters'=>[                    ['name'=>'StringTrim'],                ],                'validators'=>[                    ['name'=>'NotEmpty',                        'options'=>[                            'message'=>[                                '\Zend\Validator\NotEmpty::IS_EMPTY'=>'身份证不能为空',                            ],                        ],                    ],                ]            ]);            $this->inputFilter->add([                'name'=>'name',                'required'=>true,                'filters'=>[                    ['name'=>'StringTrim'],                ],                'validators'=>[                    ['name'=>'NotEmpty',                        'options'=>[                            'message'=>[                                '\Zend\Validator\NotEmpty::IS_EMPTY'=>'姓名不能为空',                            ],                        ],                    ],                ]            ]);            $this->inputFilter->add([                'name'=>'name',                'required'=>true,                'filters'=>[                    ['name'=>'StringTrim'],                ],                'validators'=>[                    ['name'=>'NotEmpty',                        'options'=>[                            'message'=>[                                '\Zend\Validator\NotEmpty::IS_EMPTY'=>'姓名不能为空',                            ],                        ],                    ],                ]            ]);            $this->inputFilter->add([                'name'=>'area',                'required'=>true,                'filters'=>[                    ['name'=>'StringTrim'],                ],                'validators'=>[                    ['name'=>'NotEmpty',                        'options'=>[                            'message'=>[                                '\Zend\Validator\NotEmpty::IS_EMPTY'=>'地区不能为空',                            ],                        ],                    ],                ]            ]);            $this->inputFilter->add([                'name'=>'part1',                'required'=>true,                'filters'=>[                    ['name'=>'StringTrim'],                ],                'validators'=>[                    ['name'=>'NotEmpty',                        'options'=>[                            'message'=>[                                '\Zend\Validator\NotEmpty::IS_EMPTY'=>'部门不能为空',                            ],                        ],                    ],                ]            ]);            $this->inputFilter->add([                'name'=>'company',                'required'=>true,                'filters'=>[                    ['name'=>'StringTrim'],                ],                'validators'=>[                    ['name'=>'NotEmpty',                        'options'=>[                            'message'=>[                                '\Zend\Validator\NotEmpty::IS_EMPTY'=>'公司不能为空',                            ],                        ],                    ],                ]            ]);        }        return $this->inputFilter;    } }

都是自己摸索着写的,代码有很多地方写得不够好,还请各位同行指教!!!

转载于:https://my.oschina.net/u/2618337/blog/626848

你可能感兴趣的文章
Roslyn还出现这么低级的错误,不应该呀!
查看>>
plsql 通过修改配置文件的方式实现数据库的连接
查看>>
VC++调用MSFlexGrid的SetRow方法,出现异常“Invalid Row Value”
查看>>
dubbo服务端,dubbo客户端,注册中心(zk)之间的心跳
查看>>
rapidjson使用总结
查看>>
MD5 Hashing in Java
查看>>
EMQ ---客户端上线自动订阅主题
查看>>
VSCode插件开发全攻略(五)跳转到定义、自动补全、悬停提示
查看>>
质量评估面面观--聊一聊软件上线前的质量评估
查看>>
Spring 属性配置
查看>>
unity, SerializedObject.FindProperty不要写在Editor的OnEnable里,要写在OnInspectorGUI里
查看>>
什么是佛、法、佛法和佛教
查看>>
MySQL字符串列与整数比较
查看>>
AWS Add Key Pair to Elastic Beanstalk Instance 给EB实例加密钥
查看>>
Flutter 输入控件TextField设置内容并保持光标(cursor)在末尾
查看>>
(原創) 如何重新動態配置記憶體空間? (C/C++) (C)
查看>>
(原創) 如何用管線(Pipeline)實作無號數乘加運算? (IC Design) (Verilog)
查看>>
Scrum 之 product Backlog
查看>>
英语:真正有效的英语学习心得,把英语当母语学习!(转载)
查看>>
TI公司CC系列的各种芯片的区别 CC2430 CC1100
查看>>