ignoreErrors
This page needs expansion to describe all usages of this function
Syntax
mixed function ignoreErrors( mixed $override )
Description
The function ignoreErrors()
provides a way of overriding certain aspects of error handling within ADOdb. There are 2 different behaviours based on what parameters are passed.
Parameter Format
Whether used as a setter or getter, The parameter array format is as follows:
Index | Database Setting | Description |
---|---|---|
0 | raiseErrorFn | An indication the current database object error status. This flag is set automatically if a connection or executed statement fails |
1 | _transOk | An indicator of a the current transactional status |
This array is represented by $override
in the options below.
1st Usage
If the function is used as ignoreErrors()
or ignoreErrors(false)
the following behaviour occurs:
- The database status is saved off in $override, as described above
- The raiseerrorfn flag is set to false.
- The function returns $override.
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.
/* * database connection assumed */ /* * Start a database transaction */ $db->startTrans(); /* * Update some value successfully */ $db->Execute('UPDATE some_table (field_1) VALUES "abcd");
Do some other work, which makes us decide to rollback the transaction
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 */