CodeIgniter Forums
Begin Transaction Not Work - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: Begin Transaction Not Work (/thread-71193.html)

Begin Transaction Not Work - bocahapi - 07-17-2018

Sorry everyone i need help about using trans_begin() to handle mutiple insert with multi table, im try  to insert data "Tagihan" after insert data 'Santri' but ihave a problem. in query insert data "Santri" is success but not in "Tagihan" because in "Tagihan" field "biaya_id" is unknown..

i mean with trans_begin the Data will be rollback or not insert when getting error in query...
PHP Code:


       $santri_id $this->db->insert_id();
       $kelas_id  $data['kelas_id'];

       $this->db->select('biaya_id, nominal');

       $query  $this->db->get();

       if ($query->num_rows() > 0){
           foreach ($query->result_array() as $biaya) {

       if ($this->db->trans_status() === FALSE) {

           return true;
       } else {

           return false;

RE: Begin Transaction Not Work - Pertti - 07-17-2018

Does this query in your script return expected values?
PHP Code:
$this->db->select('biaya_id, nominal');
$query  $this->db->get();