ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:ignoreerrors

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
reference:ignoreerrors [2015/07/19 23:17] – created mnewnhamv5:reference:connection:ignoreerrors [2016/01/16 23:54] (current) – ↷ Links adapted because of a move operation mnewnham
Line 1: Line 1:
 ====== ignoreErrors ====== ====== ignoreErrors ======
 ~~NOTOC~~ ~~NOTOC~~
 +<WRAP todo>
 +This page needs expansion to describe all usages of this function
 +</WRAP>
 <WRAP right box> <WRAP right box>
 == Syntax == == Syntax ==
Line 22: Line 25:
  
   - The database status is saved off in $override, as described above   - The database status is saved off in $override, as described above
-  - The [[raiseErrorFn]] flag is set to false.+  - The [[..:raiseerrorfn]] flag is set to false.
   - The function returns $override.   - The function returns $override.
      
 ==== 2nd usage ==== ==== 2nd usage ====
 +The second usage requires the construction of the array ''$override'', which can then be passed into the function. The ADODb values are then set to those values. The function returns null in this case. Best practice for usage of this function is to call it in the first way.
 +<code php>
 +/*
 + * database connection assumed
 + */
 +
 +/*
 + * Start a database transaction
 + */
 +$db->startTrans();
 +
 +/*
 + * Update some value successfully
 + */
 +$db->Execute('UPDATE some_table (field_1) VALUES "abcd");
 +
 +</code>
 +
 + Do some other work, which makes us decide to rollback the transaction
 +<code php>
 +
 +if ($resultOfWork == false) {
 +    $currentStatus = $db->ignoreErrors();
 +    
 +    /*
 +     * Force the transaction to fail
 +     */
 +    $currentStatus[1] = false;
 +    
 +    $db->ignoreErrors($currentStatus);
 +}
 +
 +$db->completeTrans();
 +/*
 + * The transaction rolls back because the $db->_transOk flag was manually
 + * set to false
 + */
 +</code>
v5/reference/connection/ignoreerrors.1437340641.txt.gz · Last modified: 2017/04/21 11:34 (external edit)