Welcome Guest, Not a member yet? Register   Sign In
trans_status wrong value
#1

PHP Code:
$this->db->trans_start();
{
    $query_str "SELECT MAX(id) max_val FROM c WHERE i = ? ";

    $query $this->db->query($query_str, array($c['i']));
    $row $query->row_array();
    
    $id 
1;
    
    if 
($row)
    {
        $id $row['max_val'] + 1;
    }
    
    $c
['id'] = $id;
    
    $this
->db->set('t''NOW()'FALSE);
    $this->db->insert('c'$c);
}
$this->db->trans_complete();

return 
$this->db->trans_status() === FALSE FALSE $c['id']; 
Hi! I'm using the above code to read the max id from a table and then add a new row with maxid + 1. I call this piece of code via an ajax call and it works the very first time. If I call it a second time, trans_status equals FALSE. This is so weird because if I refresh the whole page via F5 it works every time. What am I missing? Huh  I'm using CI 3.1.9 + Mysql InnoDB 5.6.20 (mysqli driver).
Thanks!
Reply


Messages In This Thread
trans_status wrong value - by geekita - 10-06-2018, 05:25 PM
RE: trans_status wrong value - by geekita - 10-07-2018, 02:35 AM
RE: trans_status wrong value - by php_rocs - 10-08-2018, 07:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB