Transaction status FALSE but DB error NULL |
Hi!,
I'd like to catch the sqlsrv(driver) db-error from a codeigniter transac with insert_batch: model: Code: public function sync($data) 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() 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: ![]() Why??, exists another way to capture the DB-error? Thanks in advance, Regards
I may not be correct, but I suspect it might be because insert_batch will continue to iterate through the data set even if one item in the set results in a failed insert. Subsequent inserts may succeed meaning that $this->myDB->error(); will report no problem after the batch is finished. If you can set up a test where you know the last insert will fail you should be able to test my premise.
I don't see any way to capture the error when it happens short of extending CI_DB_query_builder and overwriting inset_batch(). (05-30-2018, 02:39 PM)dave friend Wrote: I may not be correct, but I suspect it might be because insert_batch will continue to iterate through the data set even if one item in the set results in a failed insert. Subsequent inserts may succeed meaning that $this->myDB->error(); will report no problem after the batch is finished. If you can set up a test where you know the last insert will fail you should be able to test my premise. Hi, thanks. Is it possible to report this to the CI developers team?
There have been a nuymber of issues reported about batches.
I don't know if this is the same as any of them or not. You can raise an issue on our repo if this indeed appears to be a bug.
|
Welcome Guest, Not a member yet? Register Sign In |