Welcome Guest, Not a member yet? Register   Sign In
Update sql query of multiple fields not working
#1

Hi everybody, 
I'm trying to do an update query, it actually works updating one field but not with multiple fields.

Here's my code on the model:

PHP Code:
$array = array(
 
               'TIE_Nom'=>$TIE_Nom'TIE_Descripcion'=>$TIE_Descripcion'TIE_Gerent'=>$TIE_Gerent,'TIE_Telefon'=>$TIE_Telefon'TIE_Telefon2'=>$TIE_Telefon2'TIE_Telefon3'=>$TIE_Telefon3'TIE_Carrer'=>$TIE_Carrer'TIE_Carrer2'=>$TIE_Carrer2,'TIE_Carrer3'=>$TIE_Carrer3'TIE_InfoCarrer_amb_CP'=>$TIE_InfoCarrer_amb_CP'TIE_InfoOptometrista'=>$TIE_InfoOptometrista,'TIE_AudioProtesista'=>$TIE_AudioProtesista'TIE_ServeiOptom'=>$TIE_ServeiOptom,'TIE_ServeiAudio'=>$TIE_ServeiAudio'TIE_Email'=>$TIE_Email'TIE_BasePromocion'=>$TIE_BasePromocion'TIE_AliasBotiga'=>$TIE_AliasBotiga'TIE_Observacions'=>$TIE_Observacions,'TIE_Horari_Cas'=>$TIE_Horari_Cas'TIE_Horari_Cat'=>$TIE_Horari_Cat'TIE_Fichero_LOPD'=>$TIE_Fichero_LOPD'TIE_Razon_Fiscal'=>$TIE_Razon_Fiscal,'TIE_CodigoAxapta'=>$TIE_CodigoAxapta'TIE_Direccion_Fiscal'=>$TIE_Direccion_Fiscal'TIE_NIF'=>$TIE_NIF'TIE_NumeroFichero_LOPD'=>$TIE_NumeroFichero_LOPD,'TIE_CodigoINE'=>$TIE_CodigoINE'TIE_CodiPostal'=>$TIE_CodiPostal'TIE_Logo'=>$TIE_Logo'TIE_Facebook'=>$TIE_Facebook'TIE_Twitter'=>$TIE_Twitter,'TIE_Blog'=>$TIE_Blog'TIE_UrlFacebook'=>$TIE_UrlFacebook'TIE_UrlTwitter'=>$TIE_UrlTwitter,'TIE_UrlBlog'=>$TIE_UrlBlog'TIE_Web'=>$TIE_Web,'TIE_MyBusiness'=>$TIE_MyBusiness'TIE_Audio'=>$TIE_Audio'TIE_CuadrosdeMandoActivo'=>$TIE_CuadrosdeMandoActivo'TIE_Mostrar_Horari'=>$TIE_Mostrar_Horari,'TIE_Mostrar_Detalles_Cliente'=>$TIE_Mostrar_Detalles_Cliente 
            
);
$condicion "WEBLOGIN='$WEBLOGIN' AND TIE_Codigo=$TIE_Codigo";
 
           
$this
->db->trans_begin(); 

$this->db->where($condicion);

try{
 
    $this->db->update('TIENDA',$array);
}
catch (
Exception $e) {

 
    echo $e->getMessage();
}

if (
$this->db->trans_status() === FALSE){
 
                   
    $this
->db->trans_rollback();
}
else{
 
   $this->db->trans_commit();


As you can see it is a big query what I must do...
Can someone help me?  Blush
Reply
#2

Try

Code:
$this->db->where('WEBLOGIN', $WEBLOGIN);
$this->db->where('TIE_Codigo', $TIE_Codigo);
$this->db->update('TIENDA', $array);

or

Code:
$condicion = "WEBLOGIN = '{$WEBLOGIN}' AND TIE_Codigo = {$TIE_Codigo}";
$str = $this->db->update_string('TIENDA', $array, $condicion);

You don't need the transaction block if you are performing a single update.

I haven't tested the above code.

Good Luck.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB