Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework2 ZF2将空的过帐字段转换为Null_Zend Framework2 - Fatal编程技术网

Zend framework2 ZF2将空的过帐字段转换为Null

Zend framework2 ZF2将空的过帐字段转换为Null,zend-framework2,Zend Framework2,我使用字段集来填写ZF2中的表单。如果postedm为空字段,则该字段在数据库中也为空。如何在db中强制空字段为Null?在ZF2中,我认为您需要使用Zend\Filter\Null,或者根据您使用的ZF2的版本,Zend\Filter\Null在ZF2.4中不推荐使用 在字段集中,假设您正在使用Zend\InputFilter\InputFilterProviderInterface使用: public function getInputFilterSpecification() {

我使用字段集来填写ZF2中的表单。如果postedm为空字段,则该字段在数据库中也为空。如何在db中强制空字段为Null?

在ZF2中,我认为您需要使用Zend\Filter\Null,或者根据您使用的ZF2的版本,Zend\Filter\Null在ZF2.4中不推荐使用

在字段集中,假设您正在使用Zend\InputFilter\InputFilterProviderInterface使用:

public function getInputFilterSpecification()
{
    return array(
        'your_field' => array(
            'filters' => array(
                array('name' => 'ToNull'),
            ),
        ),
    );
}