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

funcion para insertar en base de datos con codeigniter

Estas en el tema de funcion para insertar en base de datos con codeigniter en el foro de CodeIgniter en Foros del Web. Buenos dias amigos del foro, solicito su ayuda con la evaluación de un codigo que deseo editar, tengo apenas una semana aprendiendo de este framework ...
  #1 (permalink)  
Antiguo 12/08/2013, 08:59
Avatar de djfc_9  
Fecha de Ingreso: agosto-2013
Ubicación: caracas
Mensajes: 1
Antigüedad: 10 años, 8 meses
Puntos: 0
Busqueda funcion para insertar en base de datos con codeigniter

Buenos dias amigos del foro, solicito su ayuda con la evaluación de un codigo que deseo editar, tengo apenas una semana aprendiendo de este framework y estoy modificando un codigo que otra persona hizo pero no encuentro por ninguna parte del mismo la instruccion que hace la insercion en la base de datos. anexo el codigo del controlador y el modelo para que lo examinen y ver si me pueden ayudar.
add_proyect_model.php (modelo)

function _set_proyect($perfil)
{
$Query = $this->db->query("SELECT * FROM dgdpt.add_proyect(
'".$this->input->post('sTipo')."'::character,
'".$this->_return_single_data($this->input->post('txtNombre'))."'::text,
'".$this->_return_single_data($this->input->post('txtOrg'))."'::text,
".$this->input->post('sEstado')."::smallint,
".$this->input->post('sMunicipio')."::smallint,
'".str_replace("'","''",$this->input->post('txtDirecc'))."'::text,
'".str_replace("'","''",$this->input->post('txtDireccI'))."'::text,
".$this->input->post('sZona')."::smallint,
'".$this->input->post('txtCi')."'::character varying,
'".$this->input->post('txtPr')."'::character varying,
'".$this->input->post('txtTlf')."'::character varying,
'".$this->input->post('txtSol')."'::date,
'".$this->input->post('txtIni')."'::date,
'".$this->input->post('txtFin')."'::date,
array[".@implode(',',$this->input->post('accion'))."]::smallint[],
array[".@implode(',',$this->input->post('prt_pre'))."]::smallint[],
array[".@implode(',',$this->input->post('activ_rlz'))."]::smallint[],
'".$this->input->post('txtBenefT')."'::smallint,
'".$this->input->post('txtEmpI')."'::smallint,
'".$this->input->post('txtMontS')."'::integer,
'".$this->input->post('txtRrhh')."'::integer,
'".$this->input->post('txtMate')."'::integer,
'".$this->input->post('txtProm')."'::integer,
'".$this->input->post('txtText')."'::integer,
'".$this->input->post('txtEdoFi')."'::integer,
'".$this->input->post('sAdmin')."'::smallint,
'".$this->input->post('sCod')."'::smallint,
'".$this->input->post('sEdo')."'::smallint,
array[".@implode(',',$this->input->post('document'))."]::smallint[],
".$this->input->post('txtSq')."::integer,
'".$this->_return_single_data($this->input->post('txtECi'))."'::character varying,
'".$this->_return_single_data($this->input->post('txtEPr'))."'::character varying,
'".$this->_return_single_data($this->input->post('txtETlf'))."'::character varying,
".$perfil->get_codigo()."::smallint,
".$this->input->post('sDirectorL')."::smallint,
".$this->input->post('sDirectorG')."::smallint,
'".$this->input->post('sRif').'-'.$this->input->post('txtRif')."'::character varying,
'".$this->input->post('txtBenefM')."'::smallint,
'".$this->input->post('txtBenefF')."'::smallint,
'".$this->_return_single_data($this->input->post('txtMail'))."'::character varying,
'".str_replace("'","''",$this->input->post('txtYy'))."'::character varying,
'".$this->input->post('txtBenefN')."'::smallint,
'".$this->input->post('txtBenefA')."'::smallint,
'".$this->input->post('txtBenefJ')."'::smallint,
'".$this->input->post('txtBenefAd')."'::smallint,
'".$this->input->post('txtBenefAdM')."'::smallint,
'".$this->input->post('txtBenefPD')."'::smallint,


'".$this->_return_single_data($this->input->post('txtNRegistro'))."'::character varying,
".$this->input->post('txtNumero')."::smallint,
".$this->input->post('txtFolio')."::smallint,
'".$this->input->post('txtMFechaComp')."'::date,
".$this->input->post('sEstado2')."::smallint,
".$this->input->post('sMunicipio2')."::smallint,
'".$this->input->post('txtParroquia')."'::character varying,
0::smallint,
".$this->input->post('txtDistribucion')."::smallint,
0::smallint


)");
$row = $Query->row();
return ($row->add_proyect == 'f') ? FALSE : TRUE;
}

add_proyect.php (controlador)


function procesar()
{
if ($this->validation->run() == FALSE)
{
$this->index();
}else
{ $perfil = unserialize($this->session->userdata('perfil'));
if($this->dbase->_set_proyect($perfil))
{
$this->load->library('perfil');
$this->load->helper ('perfil');
$this->session->set_userdata('object',serialize(build_perfil_org( $this->input->post('txtSq'))));
echo '<script language="javascript">
//<![CDATA[
var op = confirm(\'Proyecto incluido exitosamente. \'+String.fromCharCode(191)+\' Desea UD. evaluarlo ahora ?.\');
if(op){
document.location = "'. base_url() .'eval/eval_proyect/evaluar/'.$this->session->userdata('session_id').'";
}else{
document.location = "'. base_url() .'init/wlcm/";
}
//]]>
</script>';
}else{
echo '<script language="javascript">
alert("Ha ocurrido un error durante el proceso. Intente luego.");
document.location = "'. base_url() .'add/add_proyect/";
</script>';
}
unset($perfil);
}
}


estas son las funciones que se llaman.

GRACIAS DE ANTEMANO POR SU AYUDA.!
  #2 (permalink)  
Antiguo 29/09/2013, 11:07
 
Fecha de Ingreso: octubre-2011
Ubicación: USA
Mensajes: 166
Antigüedad: 12 años, 6 meses
Puntos: 19
Respuesta: funcion para insertar en base de datos con codeigniter

una funcion insert en codeigniter se define asi

Código PHP:
Ver original
  1. function _add($aadArray){
  2.         $this->db->insert('tbl_table',$aadArray);
  3.     }

donde $aadArray es un array.

Saludos

Etiquetas: funcion
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:04.