Welcome Guest, Not a member yet? Register   Sign In
Transactions do not work
#1

(This post was last modified: 07-07-2018, 10:12 AM by girub.)

hello everyone, someone will know me to say what am I wrong ...? transactions do not work or maybe something else ...
I expect that if there is an error in the insert the transaction does not even update ... instead update is always performed ...
what do you recommend?
I did a lot of tests trying also with manual transaction .. but nothing
thank you so much
Giuseppe
and sorry for my english !!

I attach the relevant code



PHP Code:
 $this->db->trans_start();

 
           foreach ($libriInVisione as $value) {

 
               $value explode("|"$value);
 
               $idMagazzino $value[0];
 
               $quantita $value[1];

 
               $this->db->set('quantita''quantita - ' $quantitafalse);
 
               $this->db->set('data_modifica_riga''NOW()'FALSE);
 
               $this->db->where('id'$idMagazzino);
 
               $this->db->update('magazzino');


 
               $this->db->set('id_cliente'$idCliente);
 
               $this->db->set('id_rappresentante'$idRappresentante);
 
               $this->db->set('id_magazzino'$idMagazzino);
 
               $this->db->set('bolla_visione'$bollaVisione);
 
               $this->db->set('quantita'$quantita);
 
               $this->db->set('quantita_visione'$quantita);

 
               //$dataVisione = '23-5-2016 23:15:23';
 
               $dataVisione_formattata date("Y-m-d"strtotime($dataVisione));

 
               $this->db->set('data_visione'$dataVisione_formattata);
 
               $this->db->set('data_inserimento_riga''NOW()'FALSE);
 
               $this->db->set('data_modifica_riga''NOW()'FALSE);
 
               $this->db->set('is_active'1);
 
               $this->db->set('operatore'$this->session->userdata['name']);

 
               $this->db->insert('in_visione');
 
           }

 
       $this->db->trans_complete();

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




Theme © iAndrew 2016 - Forum software by © MyBB