Frage

An error occurred Application error Exception information: Message: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound

My Controller:

public function insertarAction() {
        $data = $this->getRequest()->getParams();
        // extract($data);


        if (isset($data['cod_domicilio'])) {

        $municipio = new Application_Model_DbTable_Municipios();
        $datos_municipio = $municipio->todosMunicipios();
        $datos_municipio['cod_municipio']=$data['cod_municipio'];

        $localidad = new Application_Model_DbTable_Localidades();
        $datos_localidad = $localidad->buscarLocalidad();

        $datos_municipio['cod_departamento']=$datos_localidad['codigo_departamento'];

        $rowMunicipio = $municipio->createRow();
        print_r($rowMunicipio);
        $rowMunicipio->save();
        }
}

Print R at time of capture:

    array (
  'controller' => 'beneficiarios',
  'action' => 'insertar',
  'module' => 'default',
  'codigo_beneficiario' => '',
  'codigo_ud' => '2007',
  'nombres' => 'lksakljsdlkjsd',
  'apellidos' => 'lkslkjslkjsd',
  'tipo_beneficiario' => 'estudiante',
  'tipo_documento' => 'CC',
  'numero_documento' => '10912919009',
  'genero' => 'M',
  'tipo_sangre' => 'o+',
  'fecha_nacimiento' => '2013-12-12',
  'huella_d' => 'Ajustes Base de Datos',
  'huella_i' => 'Ajustes Base de Datos',
  'telefono_fijo' => '9191919',
  'telefono_celular' => '9191919191',
  'email_personal' => 'info@hola.com',
  'email_institucional' => 'info@hola.com',
  'tipo_regimen_salud' => 'sub',
  'cod_entidad_salud' => '1',
  'nombre_contacto' => 'alkslkalkakl',
  'telefono_contacto' => '18918198',
  'cod_domicilio' => '1',
  'cod_pais' => '56',
)  

The table:

CREATE TABLE IF NOT EXISTS `beneficiarios` (
  `codigo_beneficiario` int(11) NOT NULL AUTO_INCREMENT,
  `codigo_ud` bigint(20) NOT NULL,
  `nombres` varchar(30) NOT NULL,
  `apellidos` varchar(30) NOT NULL,
  `genero` enum('M','F') NOT NULL,
  `tipo_documento` enum('CC','TI','CE','P') NOT NULL,
  `numero_documento` varchar(30) NOT NULL,
  `huella_i` blob NOT NULL,
  `huella_d` blob NOT NULL,
  `telefono_fijo` varchar(8) DEFAULT NULL,
  `telefono_celular` varchar(10) DEFAULT NULL,
  `email_personal` varchar(50) NOT NULL,
  `email_institucional` varchar(50) DEFAULT NULL,
  `tipo_sangre` enum('o+','o-','a+','a-','ab+','ab-','p','b+','b-') NOT NULL,
  `fecha_nacimiento` date NOT NULL,
  `tipo_regimen_salud` enum('sub','cont') NOT NULL,
  `nombre_contacto` varchar(60) NOT NULL,
  `telefono_contacto` varchar(10) NOT NULL,
  `cod_entidad_salud` int(11) NOT NULL,
  `cod_domicilio` int(11) NOT NULL,
  `cod_pais` int(11) NOT NULL,
  `tipo_beneficiario` enum('estudiante','docente','administrativo') NOT NULL,
  PRIMARY KEY (`codigo_beneficiario`),
  KEY `fk_Beneficiario_Entidades_Salud1_idx` (`cod_entidad_salud`),
  KEY `fk_Beneficiario_Domicilios1_idx` (`cod_domicilio`),
  KEY `fk_Beneficiario_Paises1_idx` (`cod_pais`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

I am inserting the data correctly but is showing me this error, the number of entered data is the same as in the table (22 data)

War es hilfreich?

Lösung

From this Example (Example 7) in the ZF Manual, it seems you have to pass the data array, $datos_municipio to createRow() function .

$rowMunicipio = $municipio->createRow($datos_municipio);

OR

you have to set it as class properties like
$datos_municipio->cod_departamento=$datos_localidad['codigo_departamento'];

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top