You are here

function DB::errorMessage in Flickr API 5

Return a textual error message for a DB error code

Parameters

integer $value the DB error code:

Return value

string the error message or false if the error code was not recognized

3 calls to DB::errorMessage()
DB_common::errorMessage in phpFlickr/PEAR/DB/common.php
Maps a DB error code to a textual message
DB_common::raiseError in phpFlickr/PEAR/DB/common.php
Communicates an error and invoke error callbacks, etc
DB_Error::DB_Error in phpFlickr/PEAR/DB.php
DB_Error constructor

File

phpFlickr/PEAR/DB.php, line 647

Class

DB
Database independent query interface

Code

function errorMessage($value) {
  static $errorMessages;
  if (!isset($errorMessages)) {
    $errorMessages = array(
      DB_ERROR => 'unknown error',
      DB_ERROR_ACCESS_VIOLATION => 'insufficient permissions',
      DB_ERROR_ALREADY_EXISTS => 'already exists',
      DB_ERROR_CANNOT_CREATE => 'can not create',
      DB_ERROR_CANNOT_DROP => 'can not drop',
      DB_ERROR_CONNECT_FAILED => 'connect failed',
      DB_ERROR_CONSTRAINT => 'constraint violation',
      DB_ERROR_CONSTRAINT_NOT_NULL => 'null value violates not-null constraint',
      DB_ERROR_DIVZERO => 'division by zero',
      DB_ERROR_EXTENSION_NOT_FOUND => 'extension not found',
      DB_ERROR_INVALID => 'invalid',
      DB_ERROR_INVALID_DATE => 'invalid date or time',
      DB_ERROR_INVALID_DSN => 'invalid DSN',
      DB_ERROR_INVALID_NUMBER => 'invalid number',
      DB_ERROR_MISMATCH => 'mismatch',
      DB_ERROR_NEED_MORE_DATA => 'insufficient data supplied',
      DB_ERROR_NODBSELECTED => 'no database selected',
      DB_ERROR_NOSUCHDB => 'no such database',
      DB_ERROR_NOSUCHFIELD => 'no such field',
      DB_ERROR_NOSUCHTABLE => 'no such table',
      DB_ERROR_NOT_CAPABLE => 'DB backend not capable',
      DB_ERROR_NOT_FOUND => 'not found',
      DB_ERROR_NOT_LOCKED => 'not locked',
      DB_ERROR_SYNTAX => 'syntax error',
      DB_ERROR_UNSUPPORTED => 'not supported',
      DB_ERROR_TRUNCATED => 'truncated',
      DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row',
      DB_OK => 'no error',
    );
  }
  if (DB::isError($value)) {
    $value = $value
      ->getCode();
  }
  return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[DB_ERROR];
}