Welcome Guest, Not a member yet? Register   Sign In
Transaction status FALSE but DB error NULL
#1

Hi!,

I'd like to catch the sqlsrv(driver) db-error from a codeigniter transac with insert_batch:

model:

Code:
public function sync($data)
   {
       $this->myDB->trans_start();
           $this->myDB->insert_batch('myTable', $data);
           $db_error = $this->myDB->error();
       $this->myDB->trans_complete();

       if ($this->myDB->trans_status() === FALSE)
       {        
           if (!empty($db_error['message']))
           {
               return $db_error['message'];
           }
       }
       else
           return true;
   }
}

The trans_status() works fine because a SQL "string truncated" error. The problem is, accord with the CI3 system sqlsrv driver :

Code:
public function error()
   {
       $error = array('code' => '00000', 'message' => '');
       $sqlsrv_errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);

       if ( ! is_array($sqlsrv_errors))
       {
           return $error;
       }
...


the sqlsrv_errors(SQLSRV_ERR_ERRORS) returns NULL (Error number: 00000)

But if I set the CI config/database.php to 'db_debug' => TRUE, CI show that error:


[Image: ykLqU.jpg]

Why??, exists another way to capture the DB-error?

Thanks in advance,

Regards
Reply


Messages In This Thread
Transaction status FALSE but DB error NULL - by csotelo - 05-30-2018, 11:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB