Foros del Web » Programando para Internet » PHP » Zend »

[SOLUCIONADO] NoRecordExists

Estas en el tema de NoRecordExists en el foro de Zend en Foros del Web. Hola estoy tratando de hacer funcionar la validación de: NoRecordExists pero me sale un error, el cual es el siguiente: Catchable fatal error: Argument 1 ...
  #1 (permalink)  
Antiguo 14/10/2015, 11:28
Avatar de zerokull  
Fecha de Ingreso: noviembre-2009
Mensajes: 153
Antigüedad: 10 años
Puntos: 1
Pregunta NoRecordExists

Hola estoy tratando de hacer funcionar la validación de: NoRecordExists

pero me sale un error, el cual es el siguiente:

Catchable fatal error: Argument 1 passed to Zend\Validator\Db\AbstractDb::setAdapter() must be an instance of Zend\Db\Adapter\Adapter, null given, called in D:\xampp\htdocs\gestionDeArchivos\vendor\ZF2\libra ry\Zend\Validator\AbstractValidator.php on line 142 and defined in D:\xampp\htdocs\gestionDeArchivos\vendor\ZF2\libra ry\Zend\Validator\Db\AbstractDb.php on line

este es mi código:
Código PHP:
<?php
namespace AdministradorForm
;
use 
ZendInputFilterInputFilterAwareInterface;
use 
ZendInputFilterInputFilterInterface;
use 
ZendInputFilterInputFilter;
use 
ZendInputFilterFactory as InputFactory;
use 
ZendDbAdapterAdapter;

/**
 *
 * @author jose.moreno
 *        
 */
class ValidaFormClientes implements InputFilterAwareInterface
{

    protected 
$inputFilter;
    protected 
$dbAdapter;
    
   

    
/**
     * (non-PHPdoc)
     * @see \Zend\InputFilter\InputFilterAwareInterface::setInputFilter()
     */
    
public function setInputFilter (InputFilterInterface $inputFilter)
    {
        throw new 
Exception("No se usa");
    }

    
/**
     * (non-PHPdoc)
     * @see \Zend\InputFilter\InputFilterAwareInterface::getInputFilter()
     */
    
public function getInputFilter ()
    {
        
$isEmpty ZendValidatorNotEmpty::IS_EMPTY;
        
$invalidEmail ZendValidatorEmailAddress::INVALID_FORMAT;
        
$NoRecordExists ZendValidatorDbNoRecordExists::ERROR_RECORD_FOUND;
        
$regex ZendValidatorRegex::NOT_MATCH;
        
        if (! 
$this->inputFilter) {
            
$inputFilter = new InputFilter();
            
$factory = new InputFactory();
            
            
$inputFilter->add(
                    
$factory->createInput(array(
                            
'name'     => 'id_persona',
                             
'required' => true,
                             
'filters'  => array(
                                 array(
'name' => 'Int'),
                             ),
                    )));
            
            
$inputFilter->add(
                    
$factory->createInput(
                            array(
                                    
'name' => 'nombre_completo',
                                    
'required' => true,
                                    
'filters' => array(
                                            array(
                                                    
'name' => 'StripTags'
                                            
),
                                            array(
                                                    
'name' => 'StringTrim'
                                            
)
                                    ),
                                    
'validators' => array(
                                            array(
                                                    
'name' => 'NotEmpty',
                                                    
'options' => array(
                                                            
'messages' => array(
                                                                    
$isEmpty => 'Nombre no puede estar vacio.'
                                                            
),
                                                            
'encoding' => 'UTF-8',
                                                            
'min' => 5,
                                                            
'max' => 255
                                                    
),
                                                    
'break_chain_on_failure' => true
                                            
)
                                    )
                            )));
            
            
            
$inputFilter->add(
                    
$factory->createInput(array(
                            
'name' => 'rfc',
                            
'required' => true,
                            
'filters' => array(
                                    array(
'name' => 'StripTags'),
                                    array(
'name' => 'StringTrim')
                            ),
                            
'validators' => array(
                                    array(
                                            
'name' => 'NotEmpty',
                                            
'options' => array(
                                                    
'messages' => array(
                                                            
$isEmpty => 'RFC no puede estar vacio.'
                                                    
),
                                                    
'encoding' => 'UTF-8',
                                                    
'min' => 5,
                                                    
'max' => 15
                                            
),
                                            
'break_chain_on_failure' => true,                                            
                                    ),
                                    array(
                                            
'name' => 'Regex',
                                            
'options' => array(
                                                    
'pattern' => '/^([A-Z,Ñ,&]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[A-Z|\d]{3})$/',
                                                    
'messages' => array(
                                                            
$regex => 'RFC con formato invalido'
                                                    
),
                                            ),
                                    ),
                            )
                    )));
            
            
$inputFilter->add(
                
$factory->createInput(array(
                    
'name' => 'curp',
                    
'required' => true,
                    
'filters' => array(
                        array(
'name' => 'StripTags'),
                        array(
'name' => 'StringTrim')
                    ),
                    
'validators' => array(
                        array(
                            
'name' => 'NotEmpty',
                            
'options' => array(
                                
'messages' => array(
                                    
$isEmpty => 'CURP no puede estar vacio.'
                                
),
                                
'encoding' => 'UTF-8',
                                
'min' => 5,
                                
'max' => 20
                            
),
                            
'break_chain_on_failure' => true
                        
),
                        array(
                            
'name' => '\Zend\Validator\Db\NoRecordExists',
                            
'options' => array(
                                
'table' => 'personas',
                                
'field' => 'curp',
                                
'adapter' => $this->dbAdapter,
                                
'messages' => array(
                                     
ZendValidatorDbNoRecordExists::ERROR_RECORD_FOUND => 'A spouse is already defined',                                    
                                ),
                            ),
                        ),
                        array(
                            
'name' => 'Regex',
                            
'options' => array(
                                
'pattern' => '/^[A-Z]{1}[AEIOU]{1}[A-Z]{2}[0-9]{2}(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[HM]{1}(AS|BC|BS|CC|CS|CH|CL|CM|DF|DG|GT|GR|HG|JC|MC|MN|MS|NT|NL|OC|PL|QT|QR|SP|SL|SR|TC|TS|TL|VZ|YN|ZS|NE)[B-DF-HJ-NP-TV-Z]{3}[0-9A-Z]{1}[0-9]{1}$/',
                                
'messages' => array(
                                    
$regex => 'CURP con formato invalido'
                                 
),
                             ),
                        ),
                      )
                    )));
            
            
            
$this->inputFilter $inputFilter;            
        }
        return 
$this->inputFilter;        
    }
 
}
?>
espero y alguien me pueda ayudar. Saludos

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:05.