ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
MDB2.php File Reference

Go to the source code of this file.

Data Structures

class  MDB2
class  MDB2_Error
class  MDB2_Driver_Common
class  MDB2_Result
class  MDB2_Result_Common
class  MDB2_Row
class  MDB2_Statement_Common
class  MDB2_Module_Common

Namespaces

namespace  MDB2
 Several methods to convert the MDB2 native timestamp format (ISO based) to and from data structures that are convenient to worth with in side of php.

Functions

 MDB2_closeOpenTransactions ()
 Close any open transactions form persistent connections.
 MDB2_defaultDebugOutput (&$db, $scope, $message, $context=array())
 default debug output handler

Variables

const MDB2_OK = true
 The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these.
const MDB2_ERROR = -1
const MDB2_ERROR_SYNTAX = -2
const MDB2_ERROR_CONSTRAINT = -3
const MDB2_ERROR_NOT_FOUND = -4
const MDB2_ERROR_ALREADY_EXISTS = -5
const MDB2_ERROR_UNSUPPORTED = -6
const MDB2_ERROR_MISMATCH = -7
const MDB2_ERROR_INVALID = -8
const MDB2_ERROR_NOT_CAPABLE = -9
const MDB2_ERROR_TRUNCATED = -10
const MDB2_ERROR_INVALID_NUMBER = -11
const MDB2_ERROR_INVALID_DATE = -12
const MDB2_ERROR_DIVZERO = -13
const MDB2_ERROR_NODBSELECTED = -14
const MDB2_ERROR_CANNOT_CREATE = -15
const MDB2_ERROR_CANNOT_DELETE = -16
const MDB2_ERROR_CANNOT_DROP = -17
const MDB2_ERROR_NOSUCHTABLE = -18
const MDB2_ERROR_NOSUCHFIELD = -19
const MDB2_ERROR_NEED_MORE_DATA = -20
const MDB2_ERROR_NOT_LOCKED = -21
const MDB2_ERROR_VALUE_COUNT_ON_ROW = -22
const MDB2_ERROR_INVALID_DSN = -23
const MDB2_ERROR_CONNECT_FAILED = -24
const MDB2_ERROR_EXTENSION_NOT_FOUND = -25
const MDB2_ERROR_NOSUCHDB = -26
const MDB2_ERROR_ACCESS_VIOLATION = -27
const MDB2_ERROR_CANNOT_REPLACE = -28
const MDB2_ERROR_CONSTRAINT_NOT_NULL = -29
const MDB2_ERROR_DEADLOCK = -30
const MDB2_ERROR_CANNOT_ALTER = -31
const MDB2_ERROR_MANAGER = -32
const MDB2_ERROR_MANAGER_PARSE = -33
const MDB2_ERROR_LOADMODULE = -34
const MDB2_ERROR_INSUFFICIENT_DATA = -35
const MDB2_PREPARE_MANIP = false
 These are just helper constants to more verbosely express parameters to prepare()
const MDB2_PREPARE_RESULT = null
const MDB2_FETCHMODE_DEFAULT = 0
 This is a special constant that tells MDB2 the user hasn't specified any particular get mode, so the default should be used.
const MDB2_FETCHMODE_ORDERED = 1
 Column data indexed by numbers, ordered from 0 and up.
const MDB2_FETCHMODE_ASSOC = 2
 Column data indexed by column names.
const MDB2_FETCHMODE_OBJECT = 3
 Column data as object properties.
const MDB2_FETCHMODE_FLIPPED = 4
 For multi-dimensional results: normally the first level of arrays is the row number, and the second level indexed by column number or name.
const MDB2_PORTABILITY_NONE = 0
 Portability: turn off all portability features.
const MDB2_PORTABILITY_FIX_CASE = 1
 Portability: convert names of tables and fields to case defined in the "field_case" option when using the query*(), fetch*() and tableInfo() methods.
const MDB2_PORTABILITY_RTRIM = 2
 Portability: right trim the data output by query*() and fetch*().
const MDB2_PORTABILITY_DELETE_COUNT = 4
 Portability: force reporting the number of rows deleted.
const MDB2_PORTABILITY_NUMROWS = 8
 Portability: not needed in MDB2 (just left here for compatibility to DB)
const MDB2_PORTABILITY_ERRORS = 16
 Portability: makes certain error messages in certain drivers compatible with those from other DBMS's.
const MDB2_PORTABILITY_EMPTY_TO_NULL = 32
 Portability: convert empty values to null strings in data output by query*() and fetch*().
const MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES = 64
 Portability: removes database/table qualifiers from associative indexes.
const MDB2_PORTABILITY_ALL = 127
 Portability: turn on all portability features.
 $GLOBALS ['_MDB2_databases'] = array()
 These are global variables that are used to track the various class instances.
 $GLOBALS ['_MDB2_dsninfo_default']

Function Documentation

MDB2_closeOpenTransactions ( )

Close any open transactions form persistent connections.

Returns
void

public

Definition at line 4231 of file MDB2.php.

References $GLOBALS, and $key.

{
reset($GLOBALS['_MDB2_databases']);
while (next($GLOBALS['_MDB2_databases'])) {
$key = key($GLOBALS['_MDB2_databases']);
if ($GLOBALS['_MDB2_databases'][$key]->opened_persistent
&& $GLOBALS['_MDB2_databases'][$key]->in_transaction
) {
$GLOBALS['_MDB2_databases'][$key]->rollback();
}
}
}
MDB2_defaultDebugOutput ( $db,
  $scope,
  $message,
  $context = array() 
)

default debug output handler

Parameters
objectreference to an MDB2 database object
stringusually the method name that triggered the debug call: for example 'query', 'prepare', 'execute', 'parameters', 'beginTransaction', 'commit', 'rollback'
stringmessage that should be appended to the debug variable
arraycontains context information about the debug() call common keys are: is_manip, time, result etc.
Returns
void|string optionally return a modified message, this allows rewriting a query before being issued or prepared

public

Definition at line 4263 of file MDB2.php.

{
$db->debug_output.= $scope.'('.$db->db_index.'): ';
$db->debug_output.= $message.$db->getOption('log_line_break');
return $message;
}

Variable Documentation

$GLOBALS['_MDB2_databases'] = array()

These are global variables that are used to track the various class instances.

Definition at line 219 of file MDB2.php.

$GLOBALS['_MDB2_dsninfo_default']
Initial value:
array(
'phptype' => false,
'dbsyntax' => false,
'username' => false,
'password' => false,
'protocol' => false,
'hostspec' => false,
'port' => false,
'socket' => false,
'database' => false,
'mode' => false,
)

Definition at line 220 of file MDB2.php.

const MDB2_ERROR_ACCESS_VIOLATION = -27

Definition at line 94 of file MDB2.php.

Referenced by MDB2_Driver_mysql\errorInfo(), and MDB2\errorMessage().

const MDB2_ERROR_ALREADY_EXISTS = -5
const MDB2_ERROR_CANNOT_ALTER = -31

Definition at line 98 of file MDB2.php.

Referenced by MDB2_Driver_Manager_mysql\alterTable(), and MDB2\errorMessage().

const MDB2_ERROR_CANNOT_CREATE = -15
const MDB2_ERROR_CANNOT_DELETE = -16

Definition at line 83 of file MDB2.php.

Referenced by MDB2\errorMessage().

const MDB2_ERROR_CANNOT_DROP = -17

Definition at line 84 of file MDB2.php.

Referenced by MDB2_Driver_mysql\errorInfo(), and MDB2\errorMessage().

const MDB2_ERROR_CANNOT_REPLACE = -28
const MDB2_ERROR_CONNECT_FAILED = -24
const MDB2_ERROR_CONSTRAINT = -3
const MDB2_ERROR_CONSTRAINT_NOT_NULL = -29
const MDB2_ERROR_DEADLOCK = -30

Definition at line 97 of file MDB2.php.

Referenced by MDB2\errorMessage().

const MDB2_ERROR_DIVZERO = -13
const MDB2_ERROR_EXTENSION_NOT_FOUND = -25

Definition at line 92 of file MDB2.php.

Referenced by MDB2\errorMessage().

const MDB2_ERROR_INSUFFICIENT_DATA = -35

Definition at line 102 of file MDB2.php.

const MDB2_ERROR_INVALID_DATE = -12

Definition at line 79 of file MDB2.php.

Referenced by MDB2\errorMessage().

const MDB2_ERROR_INVALID_DSN = -23

Definition at line 90 of file MDB2.php.

Referenced by MDB2\errorMessage().

const MDB2_ERROR_INVALID_NUMBER = -11

Definition at line 78 of file MDB2.php.

Referenced by MDB2_Driver_oci8\errorInfo(), and MDB2\errorMessage().

const MDB2_ERROR_LOADMODULE = -34

Definition at line 101 of file MDB2.php.

Referenced by MDB2\errorMessage(), and MDB2_Driver_Common\loadModule().

const MDB2_ERROR_MANAGER = -32

Definition at line 99 of file MDB2.php.

const MDB2_ERROR_MANAGER_PARSE = -33

Definition at line 100 of file MDB2.php.

const MDB2_ERROR_MISMATCH = -7

Definition at line 74 of file MDB2.php.

Referenced by MDB2\errorMessage().

const MDB2_ERROR_NODBSELECTED = -14

Definition at line 81 of file MDB2.php.

Referenced by MDB2_Driver_mysql\errorInfo(), and MDB2\errorMessage().

const MDB2_ERROR_NOSUCHDB = -26

Definition at line 93 of file MDB2.php.

Referenced by MDB2_Driver_mysql\errorInfo(), and MDB2\errorMessage().

const MDB2_ERROR_NOSUCHFIELD = -19
const MDB2_ERROR_NOT_CAPABLE = -9

Definition at line 76 of file MDB2.php.

Referenced by MDB2\errorMessage().

const MDB2_ERROR_NOT_LOCKED = -21

Definition at line 88 of file MDB2.php.

Referenced by MDB2_Driver_mysql\errorInfo(), and MDB2\errorMessage().

const MDB2_ERROR_TRUNCATED = -10
const MDB2_ERROR_UNSUPPORTED = -6

Definition at line 73 of file MDB2.php.

Referenced by MDB2_Driver_Common\_affectedRows(), MDB2_Driver_Common\_doQuery(), MDB2_Result_Common\_getColumnNames(), MDB2_Driver_Datatype_mysql\_mapNativeDatatype(), MDB2_Driver_Datatype_oci8\_mapNativeDatatype(), MDB2_Driver_Datatype_Common\_mapNativeDatatype(), MDB2_Driver_Manager_Common\alterTable(), MDB2_Driver_mysql\beginTransaction(), MDB2_Driver_Common\beginTransaction(), MDB2_Driver_Datatype_Common\checkResultTypes(), MDB2_Driver_mysql\commit(), MDB2_Driver_Common\commit(), MDB2_Driver_Datatype_Common\compareDefinition(), MDB2_Driver_Common\connect(), MDB2_Driver_Manager_oci8\createDatabase(), MDB2_Driver_Manager_Common\createDatabase(), MDB2_Driver_Manager_Common\createSequence(), MDB2_Driver_Manager_oci8\dropDatabase(), MDB2_Driver_Manager_Common\dropDatabase(), MDB2_Driver_Manager_Common\dropSequence(), MDB2\errorMessage(), MDB2_Driver_Function_Common\executeStoredProc(), MDB2_Result_Common\fetchRow(), MDB2_Driver_Common\getOption(), MDB2_Driver_Common\getServerVersion(), MDB2_Driver_Reverse_Common\getTableConstraintDefinition(), MDB2_Driver_Reverse_Common\getTableFieldDefinition(), MDB2_Driver_Reverse_Common\getTableIndexDefinition(), MDB2_Driver_Reverse_Common\getTriggerDefinition(), MDB2_Driver_Function_Common\guid(), MDB2_Driver_Common\lastInsertID(), MDB2_Driver_Manager_Common\listDatabases(), MDB2_Driver_Manager_Common\listFunctions(), MDB2_Driver_Manager_Common\listSequences(), MDB2_Driver_Manager_Common\listTableConstraints(), MDB2_Driver_Manager_Common\listTableFields(), MDB2_Driver_Manager_Common\listTableIndexes(), MDB2_Driver_Manager_Common\listTables(), MDB2_Driver_Manager_Common\listTableTriggers(), MDB2_Driver_Manager_Common\listTableViews(), MDB2_Driver_Manager_Common\listUsers(), MDB2_Driver_Manager_Common\listViews(), MDB2_Driver_Datatype_mysql\matchPattern(), MDB2_Driver_Datatype_Common\matchPattern(), MDB2_Driver_Common\nextID(), MDB2_Result_Common\nextResult(), MDB2_Result_Common\numCols(), MDB2_Result_Common\numRows(), MDB2_Driver_Datatype_Common\quote(), MDB2_Driver_Common\replace(), MDB2_Driver_mysql\rollback(), MDB2_Driver_Common\rollback(), MDB2_Result_Common\seek(), MDB2_Driver_Common\setCharset(), MDB2_Driver_Common\setFetchMode(), MDB2_Driver_Common\setLimit(), MDB2_Driver_Common\setOption(), MDB2_Driver_oci8\setTransactionIsolation(), MDB2_Driver_mysql\setTransactionIsolation(), MDB2_Driver_Common\setTransactionIsolation(), MDB2_Driver_Common\subSelect(), MDB2_Driver_Common\supports(), and MDB2_Driver_Reverse_Common\tableInfo().

const MDB2_ERROR_VALUE_COUNT_ON_ROW = -22
const MDB2_FETCHMODE_DEFAULT = 0

This is a special constant that tells MDB2 the user hasn't specified any particular get mode, so the default should be used.

Definition at line 119 of file MDB2.php.

Referenced by MDB2_Result_oci8\fetchRow(), MDB2_Result_mysql\fetchRow(), and MDB2_BufferedResult_oci8\fetchRow().

const MDB2_FETCHMODE_FLIPPED = 4

For multi-dimensional results: normally the first level of arrays is the row number, and the second level indexed by column number or name.

MDB2_FETCHMODE_FLIPPED switches this order, so the first level of arrays is the column name, and the second level the row number.

Definition at line 142 of file MDB2.php.

const MDB2_FETCHMODE_OBJECT = 3

Column data as object properties.

Definition at line 134 of file MDB2.php.

Referenced by MDB2_Result_oci8\fetchRow(), MDB2_Result_mysql\fetchRow(), MDB2_BufferedResult_oci8\fetchRow(), and MDB2_Driver_Common\setFetchMode().

const MDB2_FETCHMODE_ORDERED = 1

Column data indexed by numbers, ordered from 0 and up.

Definition at line 124 of file MDB2.php.

Referenced by MDB2_Result_Common\fetchCol(), MDB2_Result_Common\fetchOne(), MDB2_Driver_Manager_mysql\listTables(), and MDB2_Driver_Common\setFetchMode().

const MDB2_OK = true

The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these.

If you add an error code here, make sure you also add a textual version of it in MDB2::errorMessage().

Definition at line 67 of file MDB2.php.

Referenced by MDB2_Result_Common\_assignBindColumns(), MDB2_Driver_Datatype_Common\_destroyLOB(), MDB2_Statement_oci8\_execute(), MDB2_Driver_Datatype_oci8\_retrieveLOB(), MDB2_Driver_Datatype_Common\_retrieveLOB(), MDB2_Driver_Manager_mysql\alterTable(), MDB2_Driver_Common\beginNestedTransaction(), MDB2_Driver_oci8\beginTransaction(), MDB2_Driver_mysql\beginTransaction(), MDB2_Result_Common\bindColumn(), MDB2_Statement_Common\bindParam(), MDB2_Statement_Common\bindParamArray(), MDB2_Statement_Common\bindValue(), MDB2_Statement_Common\bindValueArray(), MDB2_Driver_oci8\commit(), MDB2_Driver_mysql\commit(), MDB2_Driver_Common\completeNestedTransaction(), MDB2_Driver_mysql\connect(), MDB2_Driver_oci8\connect(), MDB2_Driver_Manager_oci8\createDatabase(), MDB2_Driver_Manager_mysql\createDatabase(), MDB2_Driver_Manager_mysql\createSequence(), MDB2_Driver_Datatype_Common\destroyLOB(), MDB2_Driver_Common\disconnect(), MDB2_Driver_Manager_mysql\dropDatabase(), MDB2\errorMessage(), MDB2_Extended\executeMultiple(), MDB2_Driver_Common\failNestedTransaction(), MDB2_Result_oci8\free(), MDB2_Result_mysql\free(), MDB2_Driver_Common\free(), MDB2_Statement_mysql\free(), MDB2_Statement_oci8\free(), MDB2_Result_Common\free(), MDB2_Statement_Common\free(), MDB2\loadClass(), MDB2_Driver_oci8\rollback(), MDB2_Driver_mysql\rollback(), MDB2_BufferedResult_oci8\seek(), MDB2_BufferedResult_mysql\seek(), MDB2_Result_Common\seek(), MDB2_Driver_Common\setFetchMode(), MDB2_Driver_Common\setLimit(), MDB2_Driver_Common\setOption(), MDB2\setOptions(), MDB2_Result_Common\setResultTypes(), MDB2_Driver_Datatype_oci8\writeLOBToFile(), and MDB2_Driver_Datatype_Common\writeLOBToFile().

const MDB2_PORTABILITY_ALL = 127

Portability: turn on all portability features.

See Also
MDB2_Driver_Common::setOption()

Definition at line 210 of file MDB2.php.

Referenced by ilDB\connect().

const MDB2_PORTABILITY_DELETE_COUNT = 4

Portability: force reporting the number of rows deleted.

See Also
MDB2_Driver_Common::setOption()

Definition at line 170 of file MDB2.php.

Referenced by MDB2_Driver_mysql\_modifyQuery().

const MDB2_PORTABILITY_EMPTY_TO_NULL = 32

Portability: convert empty values to null strings in data output by query*() and fetch*().

See Also
MDB2_Driver_Common::setOption()

Definition at line 198 of file MDB2.php.

Referenced by MDB2_Driver_Common\_fixResultArrayValues(), MDB2_Driver_Datatype_Common\_getDeclarationOptions(), ilDB\connectHost(), MDB2_Result_mysql\fetchRow(), and MDB2_Driver_Datatype_Common\quote().

const MDB2_PORTABILITY_ERRORS = 16

Portability: makes certain error messages in certain drivers compatible with those from other DBMS's.

  • mysql, mysqli: change unique/primary key constraints MDB2_ERROR_ALREADY_EXISTS -> MDB2_ERROR_CONSTRAINT
  • odbc(access): MS's ODBC driver reports 'no such field' as code 07001, which means 'too few parameters.' When this option is on that code gets mapped to MDB2_ERROR_NOSUCHFIELD.
See Also
MDB2_Driver_Common::setOption()

Definition at line 191 of file MDB2.php.

Referenced by MDB2_Driver_mysql\errorInfo().

const MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES = 64

Portability: removes database/table qualifiers from associative indexes.

See Also
MDB2_Driver_Common::setOption()

Definition at line 204 of file MDB2.php.

Referenced by MDB2_Driver_Common\_fixResultArrayValues().

const MDB2_PORTABILITY_NONE = 0

Portability: turn off all portability features.

See Also
MDB2_Driver_Common::setOption()

Definition at line 151 of file MDB2.php.

const MDB2_PORTABILITY_NUMROWS = 8

Portability: not needed in MDB2 (just left here for compatibility to DB)

See Also
MDB2_Driver_Common::setOption()

Definition at line 176 of file MDB2.php.

const MDB2_PORTABILITY_RTRIM = 2

Portability: right trim the data output by query*() and fetch*().

See Also
MDB2_Driver_Common::setOption()

Definition at line 164 of file MDB2.php.

Referenced by MDB2_Driver_Common\_fixResultArrayValues(), MDB2_Result_oci8\fetchRow(), and MDB2_BufferedResult_oci8\fetchRow().

const MDB2_PREPARE_MANIP = false

These are just helper constants to more verbosely express parameters to prepare()

Definition at line 109 of file MDB2.php.

Referenced by Log_mdb2\_prepareStatement(), MDB2_Extended\execParam(), ilDB\insert(), MDB2_Driver_oci8\prepare(), MDB2_Driver_mysql\prepare(), MDB2_Driver_Common\prepare(), ilDB\prepareManip(), ilDB\replace(), and ilDB\update().

const MDB2_PREPARE_RESULT = null

Definition at line 110 of file MDB2.php.