ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:ignoreerrors

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:

IndexDatabase SettingDescription
0raiseErrorFnAn indication the current database object error status. This flag is set automatically if a connection or executed statement fails
1_transOkAn 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:

  1. The database status is saved off in $override, as described above
  2. The raiseerrorfn flag is set to false.
  3. 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
 */
v5/reference/connection/ignoreerrors.txt · Last modified: 2016/01/16 23:54 by mnewnham