I would like to know why it does not give the error number when I enter a wrong value in the Database.
This is the Function of the Model ...
<?php
class Pacientes_model extends CI_Model {
function __construct() {
parent::__construct();
}
public function insertar($datos_paciente) {
$sql = "INSERT INTO pacientes (cod_tii_paciente, no_ide_paciente,nom1_paciente, nom2_paciente, ape1_paciente, ape2_paciente, sexo_paciente, cod_est_civil_paciente,fec_nac_paciente, cod_ocup_paciente, dir_paciente, tel_paciente, cel_paciente) "
. "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
$resultado = $query_result = $this->db->query($sql, $datos_paciente);
if ($resultado) {
return $this->db->affected_rows();
} else {
return $this->db->_error_number();
}
}
}
This is the driver code
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Pacientes extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Pacientes_model');
}
public function clientes() {
$this->load->model('pacientes_model');
}
public function guardar() {
if ($this->input->is_ajax_request())
$datos_paciente = ['cod_tii_paciente' => $this->input->post('sel_ti'),
'no_ide_paciente' => $this->input->post('text_nro_ide'),
'nom1_paciente' => trim(strtolower($this->input->post('text_nom1'))),
'nom2_paciente' => trim(strtolower($this->input->post('text_nom2'))),
'ape1_paciente' => trim(strtolower($this->input->post('text_ape1'))),
'ape2_paciente' => trim(strtolower($this->input->post('text_ape2'))),
'sexo_paciente' => $this->input->post('sel_sexo'),
'cod_est_civil_paciente' => $this->input->post('sel_ec'),
'fec_nac_paciente' => $this->input->post('text_fec_nac'),
'cod_ocup_paciente' => $this->input->post('text_cod_ocup'),
'dir_paciente' => trim(strtolower($this->input->post('text_dir'))),
'tel_paciente' => trim($this->input->post('text_tel')),
'cel_paciente' => trim($this->input->post('text_cel'))];
$message = $this->Pacientes_model->insertar($datos_paciente);
if ($message) {
echo $message;
} else {
echo $message;
}
}
}
}