; * @copyright Tommy Gildseth, September 2004 * @version 0.1 * @access public * @package DBTableInfo */ class DBOError extends PEAR_Error { //{{{ Class members /** * Array of error code to error message mappings. * * @access private */ var $_messages = array(DBO_ERROR => 'Unknown error', DBO_MISSING_COLUMN => "The following columns are missing a value, but are mandatory:\n", DBO_NOT_MODIFIED => 'No values was modified', DBO_UPDATE_FAILED => "Unable to update row. Pear DB_Error says:\n", DBO_INSERT_FAILED => "Unable to insert row. Pear DB_Error says:\n", DBO_SELECT_FAILED => "No rows found.", DBO_SELECT_EMPTY => "No rows found.", DBO_ARGUMENT_IS_NOT_ARRAY => "The supplied value parameter is not an array in method ", DBO_NOT_AVAILABLE => "The method you requested is not available for this class"); // }}} // {{{ constructor DBOError(int code) /** * DBInfoError constructor. * * @param int $code error code * @param mixed $info Depending on the error code, this can be an array * or a DB_Error object. * @access public */ function DBOError($code = DBO_ERROR, $info = null) { switch($code) { case DBO_MISSING_COLUMN: $msg = implode("\n", $info); break; case DBO_INSERT_FAILED: case DBO_UPDATE_FAILED: case DBO_SELECT_FAILED: $msg = "DB_Error message: ".$info->getMessage(); $msg .= "\nNative message:".$info->getUserInfo(); $msg .= "\nNative message:".$info->getDebugInfo(); case DBO_ARGUMENT_IS_NOT_ARRAY: $msg = $info; break; default: $msg = ''; } $this->PEAR_Error('DBObject Error: ' . $this->_messages[$code].$msg, $code, PEAR_ERROR_RETURN, E_USER_NOTICE); } // }}} } ?>