Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.1.3

Request #16789 how to catch exception while using tableBrowser
Submitted: 2009-11-15 11:14 UTC
From: heivin Assigned:
Status: Verified Package: MDB2_TableBrowser (version 0.1.1)
PHP Version: 5.2.4 OS: XP
Roadmaps: (Not assigned)    
Subscription  


 [2009-11-15 11:14 UTC] heivin (Heivin Woo)
Description: ------------ As I try to catch the exception throw by tableBrowser while insert a row which call "MDB2 Error: null value violates not-null constraint " try { $browser->insertRow($arr); }catch (MDB2_TableBrowser_DBException $e) { do sth. } but it seems like haven't throw a exception but ouput error message from $this->mdb2->extended->executeMultiple Can anyone tell me how to catch exception here? Expected result: ---------------- Can anyone tell me how to catch exception here?

Comments

 [2009-11-16 06:28 UTC] tewolde (Isaac Tewolde)
Insert operations are always done in batch, so the problem in your case may be that some of the insert operations are executing fine but others are failing. A possible workaround is to find the number of affected rows being returned...this is what it returns if any of the insert operations succeeded. If they are less than the number of rows being inserted then you can detect the problem. At that point you can abort the transaction, or deal with it appropriately.
 [2009-11-16 06:40 UTC] tewolde (Isaac Tewolde)
-Status: Open +Status: Verified
It makes sense to add this test to the table browser itself and then raise the exception there.
 [2009-11-18 11:57 UTC] heivin (Heivin Woo)
-Status: Open +Status: Verified can this be more specific? thanks :)
 [2009-11-19 07:05 UTC] tewolde (Isaac Tewolde)
Instead of this: ######### try { $browser->insertRow($arr); }catch (MDB2_TableBrowser_DBException $e) { do sth. } Do this: ##### try { $numRows = count($arr); $numInserted = $browser->insertRow($arr); if($numInserted < $numRows){ //Some inserted have failed deal with the error here... } }catch (MDB2_TableBrowser_DBException $e) { do sth. }