ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
MDB2_Driver_Common Class Reference
+ Inheritance diagram for MDB2_Driver_Common:
+ Collaboration diagram for MDB2_Driver_Common:

Public Member Functions

 __construct ()
 Constructor. More...
 
 MDB2_Driver_Common ()
 PHP 4 Constructor. More...
 
 __destruct ()
 Destructor. More...
 
 free ()
 Free the internal references so that the instance can be destroyed. More...
 
 __toString ()
 String conversation. More...
 
 errorInfo ($error=null)
 This method is used to collect information about an error. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is used to communicate an error and invoke error callbacks etc. More...
 
 resetWarnings ()
 reset the warning array More...
 
 getWarnings ()
 Get all warnings in reverse order. More...
 
 setFetchMode ($fetchmode, $object_class='stdClass')
 Sets which fetch mode should be used by default on queries on this connection. More...
 
 setOption ($option, $value)
 set the option for the db class More...
 
 getOption ($option)
 Returns the value of an option. More...
 
 debug ($message, $scope='', $context=array())
 set a debug message More...
 
 getDebugOutput ()
 output debug info More...
 
 escape ($text, $escape_wildcards=false)
 Quotes a string so it can be safely used in a query. More...
 
 escapePattern ($text)
 Quotes pattern (% and _) characters in a string) More...
 
 quoteIdentifier ($str, $check_option=false)
 Quote a string so it can be safely used as a table or column name. More...
 
 getAsKeyword ()
 Gets the string to alias column. More...
 
 getConnection ()
 Returns a native connection. More...
 
 _fixResultArrayValues (&$row, $mode)
 Do all necessary conversions on result arrays to fix DBMS quirks. More...
 
loadModule ($module, $property=null, $phptype_specific=null)
 loads a module More...
 
 __call ($method, $params)
 Calls a module method using the __call magic method. More...
 
 beginTransaction ($savepoint=null)
 Start a transaction or set a savepoint. More...
 
 commit ($savepoint=null)
 Commit the database changes done during a transaction that is in progress or release a savepoint. More...
 
 rollback ($savepoint=null)
 Cancel any database changes done during a transaction or since a specific savepoint that is in progress. More...
 
 inTransaction ($ignore_nested=false)
 If a transaction is currently open. More...
 
 setTransactionIsolation ($isolation, $options=array())
 Set the transacton isolation level. More...
 
 beginNestedTransaction ()
 Start a nested transaction. More...
 
 completeNestedTransaction ($force_rollback=false)
 Finish a nested transaction by rolling back if an error occured or committing otherwise. More...
 
 failNestedTransaction ($error=null, $immediately=false)
 Force setting nested transaction to failed. More...
 
 getNestedTransactionError ()
 The first error that occured since the transaction start. More...
 
 connect ()
 Connect to the database. More...
 
 setCharset ($charset, $connection=null)
 Set the charset on the current connection. More...
 
 disconnect ($force=true)
 Log out and disconnect from the database. More...
 
 setDatabase ($name)
 Select a different database. More...
 
 getDatabase ()
 Get the current database. More...
 
 setDSN ($dsn)
 set the DSN More...
 
 getDSN ($type='string', $hidepw=false)
 return the DSN as a string More...
 
standaloneQuery ($query, $types=null, $is_manip=false)
 execute a query as database administrator More...
 
 _modifyQuery ($query, $is_manip, $limit, $offset)
 Changes a query string for various DBMS specific reasons. More...
 
_doQuery ($query, $is_manip=false, $connection=null, $database_name=null)
 Execute a query. More...
 
 _affectedRows ($connection, $result=null)
 Returns the number of rows affected. More...
 
exec ($query)
 Execute a manipulation query to the database and return the number of affected rows. More...
 
query ($query, $types=null, $result_class=true, $result_wrap_class=false)
 Send a query to the database and return any results. More...
 
_wrapResult ($result, $types=array(), $result_class=true, $result_wrap_class=false, $limit=null, $offset=null)
 wrap a result set into the correct class More...
 
 getServerVersion ($native=false)
 return version information about the server More...
 
 setLimit ($limit, $offset=null)
 set the range of the next query More...
 
 subSelect ($query, $type=false)
 simple subselect emulation: leaves the query untouched for all RDBMS that support subselects More...
 
 replace ($table, $fields)
 Execute a SQL REPLACE query. More...
 
prepare ($query, $types=null, $result_types=null, $lobs=array())
 Prepares a query for multiple execution with execute(). More...
 
 _skipDelimitedStrings ($query, $position, $p_position)
 Utility method, used by prepare() to avoid replacing placeholders within delimited strings. More...
 
 quote ($value, $type=null, $quote=true, $escape_wildcards=false)
 Convert a text value into a DBMS specific format that is suitable to compose query statements. More...
 
 getDeclaration ($type, $name, $field)
 Obtain DBMS specific SQL code portion needed to declare of the given type. More...
 
 compareDefinition ($current, $previous)
 Obtain an array of changes that may need to applied. More...
 
 supports ($feature)
 Tell whether a DB implementation or its backend extension supports a given feature. More...
 
 getSequenceName ($sqn)
 adds sequence name formatting to a sequence name More...
 
 getIndexName ($idx)
 adds index name formatting to a index name More...
 
 nextID ($seq_name, $ondemand=true)
 Returns the next free id of a sequence. More...
 
 lastInsertID ($table=null, $field=null)
 Returns the autoincrement ID if supported or $id or fetches the current ID in a sequence called: $table. More...
 
 currID ($seq_name)
 Returns the current id of a sequence. More...
 
 queryOne ($query, $type=null, $colnum=0)
 Execute the specified query, fetch the value from the first column of the first row of the result set and then frees the result set. More...
 
 queryRow ($query, $types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT)
 Execute the specified query, fetch the values from the first row of the result set into an array and then frees the result set. More...
 
 queryCol ($query, $type=null, $colnum=0)
 Execute the specified query, fetch the value from the first column of each row of the result set into an array and then frees the result set. More...
 
 queryAll ($query, $types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT, $rekey=false, $force_array=false, $group=false)
 Execute the specified query, fetch all the rows of the result set into a two dimensional array and then frees the result set. More...
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $db_index = 0
 
 $dsn = array()
 
 $connected_dsn = array()
 
 $connection = 0
 
 $opened_persistent
 
 $database_name = ''
 
 $connected_database_name = ''
 
 $connected_server_info = ''
 
 $supported
 
 $options
 
 $string_quoting = array('start' => "'", 'end' => "'", 'escape' => false, 'escape_pattern' => false)
 
 $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"')
 
 $sql_comments
 
 $wildcards = array('%', '_')
 
 $as_keyword = ' AS '
 
 $warnings = array()
 
 $debug_output = ''
 
 $in_transaction = false
 
 $nested_transaction_counter = null
 
 $has_transaction_error = false
 
 $offset = 0
 
 $limit = 0
 
 $phptype
 
 $dbsyntax
 
 $last_query
 
 $fetchmode = MDB2_FETCHMODE_ORDERED
 
 $modules = array()
 
 $destructor_registered = true
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Additional Inherited Members

- Static Public Member Functions inherited from PEAR
static & getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 

Detailed Description

Definition at line 994 of file MDB2.php.

Constructor & Destructor Documentation

◆ __construct()

MDB2_Driver_Common::__construct ( )

Constructor.

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 1301 of file MDB2.php.

1302 {
1303 end($GLOBALS['_MDB2_databases']);
1304 $db_index = key($GLOBALS['_MDB2_databases']) + 1;
1305 $GLOBALS['_MDB2_databases'][$db_index] = &$this;
1306 $this->db_index = $db_index;
1307 }
$GLOBALS['_MDB2_databases']
These are global variables that are used to track the various class instances.
Definition: MDB2.php:224

References $db_index, and $GLOBALS.

Referenced by MDB2_Driver_Common().

+ Here is the caller graph for this function:

◆ __destruct()

MDB2_Driver_Common::__destruct ( )

Destructor.

Definition at line 1327 of file MDB2.php.

1328 {
1329 $this->disconnect(false);
1330 }
disconnect($force=true)
Log out and disconnect from the database.
Definition: MDB2.php:2247

References disconnect().

+ Here is the call graph for this function:

Member Function Documentation

◆ __call()

MDB2_Driver_Common::__call (   $method,
  $params 
)

Calls a module method using the __call magic method.

Parameters
stringMethod name.
arrayArguments.
Returns
mixed Returned value.

Definition at line 1920 of file MDB2.php.

1921 {
1922 $module = null;
1923 if (preg_match('/^([a-z]+)([A-Z])(.*)$/', $method, $match)
1924 && isset($this->options['modules'][$match[1]])
1925 ) {
1926 $module = $this->options['modules'][$match[1]];
1927 $method = strtolower($match[2]).$match[3];
1928 if (!isset($this->modules[$module]) || !is_object($this->modules[$module])) {
1929 $result =& $this->loadModule($module);
1930 if (PEAR::isError($result)) {
1931 return $result;
1932 }
1933 }
1934 } else {
1935 foreach ($this->modules as $key => $foo) {
1936 if (is_object($this->modules[$key])
1937 && method_exists($this->modules[$key], $method)
1938 ) {
1939 $module = $key;
1940 break;
1941 }
1942 }
1943 }
1944 if (!is_null($module)) {
1945 return call_user_func_array(array(&$this->modules[$module], $method), $params);
1946 }
1947 trigger_error(sprintf('Call to undefined function: %s::%s().', get_class($this), $method), E_USER_ERROR);
1948 }
sprintf('%.4f', $callTime)
$result
& loadModule($module, $property=null, $phptype_specific=null)
loads a module
Definition: MDB2.php:1851
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
$key
Definition: croninfo.php:18
if($modEnd===false) $module
Definition: module.php:59
$params
Definition: disable.php:11

References $key, $module, $params, $result, PEAR\isError(), loadModule(), and sprintf.

+ Here is the call graph for this function:

◆ __toString()

MDB2_Driver_Common::__toString ( )

String conversation.

Returns
string representation of the object

@access public

Definition at line 1359 of file MDB2.php.

1360 {
1361 $info = get_class($this);
1362 $info.= ': (phptype = '.$this->phptype.', dbsyntax = '.$this->dbsyntax.')';
1363 if ($this->connection) {
1364 $info.= ' [connected]';
1365 }
1366 return $info;
1367 }
$info
Definition: index.php:5

References $info.

◆ _affectedRows()

MDB2_Driver_Common::_affectedRows (   $connection,
  $result = null 
)

Returns the number of rows affected.

Parameters
resourceresult handle
resourceconnection handle
Returns
mixed MDB2 Error Object or the number of rows affected

@access private

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2458 of file MDB2.php.

2459 {
2460 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2461 'method not implemented', __FUNCTION__);
2462 }
const MDB2_ERROR_UNSUPPORTED
Definition: MDB2.php:78
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is used to communicate an error and invoke error callbacks etc.
Definition: MDB2.php:1412

References MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by exec(), replace(), and standaloneQuery().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _doQuery()

& MDB2_Driver_Common::_doQuery (   $query,
  $is_manip = false,
  $connection = null,
  $database_name = null 
)

Execute a query.

Parameters
stringquery
boolif the query is a manipulation query
resourceconnection handle
stringdatabase name
Returns
result or error object

@access protected

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2430 of file MDB2.php.

2431 {
2432 $this->last_query = $query;
2433 $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
2434 if ($result) {
2435 if (PEAR::isError($result)) {
2436 return $result;
2437 }
2438 $query = $result;
2439 }
2440 $err =& $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2441 'method not implemented', __FUNCTION__);
2442 return $err;
2443 }
debug($message, $scope='', $context=array())
set a debug message
Definition: MDB2.php:1593
$query

References $query, $result, debug(), PEAR\isError(), MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by exec(), query(), replace(), and standaloneQuery().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fixResultArrayValues()

MDB2_Driver_Common::_fixResultArrayValues ( $row,
  $mode 
)

Do all necessary conversions on result arrays to fix DBMS quirks.

Parameters
arraythe array to be fixed (passed by reference)
arraybit-wise addition of the required portability modes
Returns
void

@access protected

Definition at line 1766 of file MDB2.php.

1767 {
1768 switch ($mode) {
1770 foreach ($row as $key => $value) {
1771 if ($value === '') {
1772 $row[$key] = null;
1773 }
1774 }
1775 break;
1777 foreach ($row as $key => $value) {
1778 if (is_string($value)) {
1779 $row[$key] = rtrim($value);
1780 }
1781 }
1782 break;
1784 $tmp_row = array();
1785 foreach ($row as $key => $value) {
1786 $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value;
1787 }
1788 $row = $tmp_row;
1789 break;
1791 foreach ($row as $key => $value) {
1792 if ($value === '') {
1793 $row[$key] = null;
1794 } elseif (is_string($value)) {
1795 $row[$key] = rtrim($value);
1796 }
1797 }
1798 break;
1800 $tmp_row = array();
1801 foreach ($row as $key => $value) {
1802 if (is_string($value)) {
1803 $value = rtrim($value);
1804 }
1805 $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value;
1806 }
1807 $row = $tmp_row;
1808 break;
1810 $tmp_row = array();
1811 foreach ($row as $key => $value) {
1812 if ($value === '') {
1813 $value = null;
1814 }
1815 $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value;
1816 }
1817 $row = $tmp_row;
1818 break;
1820 $tmp_row = array();
1821 foreach ($row as $key => $value) {
1822 if ($value === '') {
1823 $value = null;
1824 } elseif (is_string($value)) {
1825 $value = rtrim($value);
1826 }
1827 $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value;
1828 }
1829 $row = $tmp_row;
1830 break;
1831 }
1832 }
const MDB2_PORTABILITY_RTRIM
Portability: right trim the data output by query*() and fetch*().
Definition: MDB2.php:169
const MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES
Portability: removes database/table qualifiers from associative indexes.
Definition: MDB2.php:209
const MDB2_PORTABILITY_EMPTY_TO_NULL
Portability: convert empty values to null strings in data output by query*() and fetch*().
Definition: MDB2.php:203

References $key, $row, MDB2_PORTABILITY_EMPTY_TO_NULL, MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES, and MDB2_PORTABILITY_RTRIM.

◆ _modifyQuery()

MDB2_Driver_Common::_modifyQuery (   $query,
  $is_manip,
  $limit,
  $offset 
)

Changes a query string for various DBMS specific reasons.

Parameters
stringquery to modify
boolif it is a DML query
intlimit the number of rows
intstart reading from given offset
Returns
string modified query

@access protected

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2411 of file MDB2.php.

2412 {
2413 return $query;
2414 }

References $query.

Referenced by exec(), query(), and standaloneQuery().

+ Here is the caller graph for this function:

◆ _skipDelimitedStrings()

MDB2_Driver_Common::_skipDelimitedStrings (   $query,
  $position,
  $p_position 
)

Utility method, used by prepare() to avoid replacing placeholders within delimited strings.

Check if the placeholder is contained within a delimited string. If so, skip it and advance the position, otherwise return the current position, which is valid

Parameters
string$query
integer$positioncurrent string cursor position
integer$p_positionplaceholder position
Returns
mixed integer $new_position on success MDB2_Error on failure

@access protected

Definition at line 2974 of file MDB2.php.

2975 {
2976 $ignores = $this->sql_comments;
2977 $ignores[] = $this->string_quoting;
2978 $ignores[] = $this->identifier_quoting;
2979
2980 foreach ($ignores as $ignore) {
2981 if (!empty($ignore['start'])) {
2982 if (is_int($start_quote = strpos($query, $ignore['start'], $position)) && $start_quote < $p_position) {
2983 $end_quote = $start_quote;
2984 do {
2985 if (!is_int($end_quote = strpos($query, $ignore['end'], $end_quote + 1))) {
2986 if ($ignore['end'] === "\n") {
2987 $end_quote = strlen($query) - 1;
2988 } else {
2989 $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
2990 'query with an unterminated text string specified', __FUNCTION__);
2991 return $err;
2992 }
2993 }
2994 } while ($ignore['escape'] && $query[($end_quote - 1)] == $ignore['escape']);
2995 $position = $end_quote + 1;
2996 return $position;
2997 }
2998 }
2999 }
3000 return $position;
3001 }
const MDB2_ERROR_SYNTAX
Definition: MDB2.php:74
while(false !==( $line=fgets( $in))) if(! $columns) $ignore
Definition: Utf8Test.php:63

References $identifier_quoting, $ignore, $query, $sql_comments, $string_quoting, MDB2_ERROR_SYNTAX, and raiseError().

Referenced by prepare(), MDB2_Driver_mysql\prepare(), MDB2_Driver_mysqli\prepare(), MDB2_Driver_oci8\prepare(), and MDB2_Driver_pgsql\prepare().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _wrapResult()

& MDB2_Driver_Common::_wrapResult (   $result,
  $types = array(),
  $result_class = true,
  $result_wrap_class = false,
  $limit = null,
  $offset = null 
)

wrap a result set into the correct class

Parameters
resourceresult handle
mixedarray that contains the types of the columns in the result set
mixedstring which specifies which result class to use
mixedstring which specifies which class to wrap results in
stringnumber of rows to select
stringfirst row to select
Returns
mixed an MDB2_Result, a MDB2 error on failure

@access protected

Definition at line 2552 of file MDB2.php.

2554 {
2555 if ($types === true) {
2556 if ($this->supports('result_introspection')) {
2557 $this->loadModule('Reverse', null, true);
2558 $tableInfo = $this->reverse->tableInfo($result);
2559 if (PEAR::isError($tableInfo)) {
2560 return $tableInfo;
2561 }
2562 $types = array();
2563 foreach ($tableInfo as $field) {
2564 $types[] = $field['mdb2type'];
2565 }
2566 } else {
2567 $types = null;
2568 }
2569 }
2570
2571 if ($result_class === true) {
2572 $result_class = $this->options['result_buffering']
2573 ? $this->options['buffered_result_class'] : $this->options['result_class'];
2574 }
2575
2576 if ($result_class) {
2577 $class_name = sprintf($result_class, $this->phptype);
2578 if (!MDB2::classExists($class_name)) {
2579 $err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
2580 'result class does not exist '.$class_name, __FUNCTION__);
2581 return $err;
2582 }
2583 $result = new $class_name($this, $result, $limit, $offset);
2585 $err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
2586 'result class is not extended from MDB2_Result_Common', __FUNCTION__);
2587 return $err;
2588 }
2589 if (!empty($types)) {
2590 $err = $result->setResultTypes($types);
2591 if (PEAR::isError($err)) {
2592 $result->free();
2593 return $err;
2594 }
2595 }
2596 }
2597 if ($result_wrap_class === true) {
2598 $result_wrap_class = $this->options['result_wrap_class'];
2599 }
2600 if ($result_wrap_class) {
2601 if (!MDB2::classExists($result_wrap_class)) {
2602 $err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
2603 'result wrap class does not exist '.$result_wrap_class, __FUNCTION__);
2604 return $err;
2605 }
2606 $result = new $result_wrap_class($result, $this->fetchmode);
2607 }
2608 return $result;
2609 }
const MDB2_ERROR_NOT_FOUND
Definition: MDB2.php:76
supports($feature)
Tell whether a DB implementation or its backend extension supports a given feature.
Definition: MDB2.php:3092
classExists($classname)
Checks if a class exists without triggering __autoload.
Definition: MDB2.php:309
isResultCommon($value)
Tell whether a value is a MDB2 result implementing the common interface.
Definition: MDB2.php:660

References $limit, $offset, $result, MDB2\classExists(), PEAR\isError(), MDB2\isResultCommon(), loadModule(), MDB2_ERROR_NOT_FOUND, raiseError(), sprintf, and supports().

Referenced by query(), standaloneQuery(), MDB2_Driver_oci8\standaloneQuery(), and MDB2_Driver_pgsql\standaloneQuery().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ beginNestedTransaction()

MDB2_Driver_Common::beginNestedTransaction ( )

Start a nested transaction.

EXPERIMENTAL

WARNING: this function is experimental and may change signature at any time until labelled as non-experimental

Returns
mixed MDB2_OK on success/savepoint name, a MDB2 error on failure

@access public

Since
2.1.1

Definition at line 2074 of file MDB2.php.

2075 {
2076 if ($this->in_transaction) {
2078 $savepoint = sprintf($this->options['savepoint_format'], $this->nested_transaction_counter);
2079 if ($this->supports('savepoints') && $savepoint) {
2080 return $this->beginTransaction($savepoint);
2081 }
2082 return MDB2_OK;
2083 }
2084 $this->has_transaction_error = false;
2085 $result = $this->beginTransaction();
2086 $this->nested_transaction_counter = 1;
2087 return $result;
2088 }
const MDB2_OK(!class_exists('PEAR'))
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these.
Definition: MDB2.php:72
beginTransaction($savepoint=null)
Start a transaction or set a savepoint.
Definition: MDB2.php:1961

References $nested_transaction_counter, $result, beginTransaction(), MDB2_OK, sprintf, and supports().

+ Here is the call graph for this function:

◆ beginTransaction()

MDB2_Driver_Common::beginTransaction (   $savepoint = null)

Start a transaction or set a savepoint.

Parameters
stringname of a savepoint to set
Returns
mixed MDB2_OK on success, a MDB2 error on failure

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 1961 of file MDB2.php.

1962 {
1963 $this->debug('Starting transaction', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
1964 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1965 'transactions are not supported', __FUNCTION__);
1966 }

References debug(), MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by beginNestedTransaction(), and replace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commit()

MDB2_Driver_Common::commit (   $savepoint = null)

Commit the database changes done during a transaction that is in progress or release a savepoint.

This function may only be called when auto-committing is disabled, otherwise it will fail. Therefore, a new transaction is implicitly started after committing the pending changes.

Parameters
stringname of a savepoint to release
Returns
mixed MDB2_OK on success, a MDB2 error on failure

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 1982 of file MDB2.php.

1983 {
1984 $this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
1985 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1986 'commiting transactions is not supported', __FUNCTION__);
1987 }

References debug(), MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by completeNestedTransaction(), and replace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compareDefinition()

MDB2_Driver_Common::compareDefinition (   $current,
  $previous 
)

Obtain an array of changes that may need to applied.

Parameters
arraynew definition
arrayold definition
Returns
array containing all changes that will need to be applied

@access public

Definition at line 3068 of file MDB2.php.

3069 {
3070 $result = $this->loadModule('Datatype', null, true);
3071 if (PEAR::isError($result)) {
3072 return $result;
3073 }
3074 return $this->datatype->compareDefinition($current, $previous);
3075 }

References $current, $result, PEAR\isError(), and loadModule().

+ Here is the call graph for this function:

◆ completeNestedTransaction()

MDB2_Driver_Common::completeNestedTransaction (   $force_rollback = false)

Finish a nested transaction by rolling back if an error occured or committing otherwise.

EXPERIMENTAL

WARNING: this function is experimental and may change signature at any time until labelled as non-experimental

Parameters
boolif the transaction should be rolled back regardless even if no error was set within the nested transaction
Returns
mixed MDB_OK on commit/counter decrementing, false on rollback and a MDB2 error on failure

@access public

Since
2.1.1

Definition at line 2110 of file MDB2.php.

2111 {
2112 if ($this->nested_transaction_counter > 1) {
2113 $savepoint = sprintf($this->options['savepoint_format'], $this->nested_transaction_counter);
2114 if ($this->supports('savepoints') && $savepoint) {
2115 if ($force_rollback || $this->has_transaction_error) {
2116 $result = $this->rollback($savepoint);
2117 if (!PEAR::isError($result)) {
2118 $result = false;
2119 $this->has_transaction_error = false;
2120 }
2121 } else {
2122 $result = $this->commit($savepoint);
2123 }
2124 } else {
2125 $result = MDB2_OK;
2126 }
2128 return $result;
2129 }
2130
2131 $this->nested_transaction_counter = null;
2132 $result = MDB2_OK;
2133
2134 // transaction has not yet been rolled back
2135 if ($this->in_transaction) {
2136 if ($force_rollback || $this->has_transaction_error) {
2137 $result = $this->rollback();
2138 if (!PEAR::isError($result)) {
2139 $result = false;
2140 }
2141 } else {
2142 $result = $this->commit();
2143 }
2144 }
2145 $this->has_transaction_error = false;
2146 return $result;
2147 }
rollback($savepoint=null)
Cancel any database changes done during a transaction or since a specific savepoint that is in progre...
Definition: MDB2.php:2003
commit($savepoint=null)
Commit the database changes done during a transaction that is in progress or release a savepoint.
Definition: MDB2.php:1982

References $nested_transaction_counter, $result, commit(), PEAR\isError(), MDB2_OK, rollback(), sprintf, and supports().

+ Here is the call graph for this function:

◆ connect()

MDB2_Driver_Common::connect ( )

Connect to the database.

Returns
true on success, MDB2 Error Object on failure

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2210 of file MDB2.php.

2211 {
2212 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2213 'method not implemented', __FUNCTION__);
2214 }

References MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by getConnection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currID()

MDB2_Driver_Common::currID (   $seq_name)

Returns the current id of a sequence.

Parameters
stringname of the sequence
Returns
mixed MDB2 Error Object or id

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, and MDB2_Driver_pgsql.

Definition at line 3188 of file MDB2.php.

3189 {
3190 $this->warnings[] = 'database does not support getting current
3191 sequence value, the sequence value was incremented';
3192 return $this->nextID($seq_name);
3193 }
nextID($seq_name, $ondemand=true)
Returns the next free id of a sequence.
Definition: MDB2.php:3150

References nextID().

+ Here is the call graph for this function:

◆ debug()

MDB2_Driver_Common::debug (   $message,
  $scope = '',
  $context = array() 
)

set a debug message

Parameters
stringmessage that should be appended to the debug variable
stringusually the method name that triggered the debug call: for example 'query', 'prepare', 'execute', 'parameters', 'beginTransaction', 'commit', 'rollback'
arraycontains context information about the debug() call common keys are: is_manip, time, result etc.
Returns
void

@access public

Definition at line 1593 of file MDB2.php.

1594 {
1595 if ($this->options['debug'] && $this->options['debug_handler']) {
1596 if (!$this->options['debug_expanded_output']) {
1597 if (!empty($context['when']) && $context['when'] !== 'pre') {
1598 return null;
1599 }
1600 $context = empty($context['is_manip']) ? false : $context['is_manip'];
1601 }
1602 return call_user_func_array($this->options['debug_handler'], array(&$this, $scope, $message, $context));
1603 }
1604 return null;
1605 }
catch(Exception $e) $message

References $message.

Referenced by _doQuery(), MDB2_Driver_mysql\_doQuery(), MDB2_Driver_mysqli\_doQuery(), MDB2_Driver_oci8\_doQuery(), MDB2_Driver_pgsql\_doQuery(), beginTransaction(), MDB2_Driver_mysql\beginTransaction(), MDB2_Driver_mysqli\beginTransaction(), MDB2_Driver_oci8\beginTransaction(), MDB2_Driver_pgsql\beginTransaction(), commit(), MDB2_Driver_mysql\commit(), MDB2_Driver_mysqli\commit(), MDB2_Driver_oci8\commit(), MDB2_Driver_pgsql\commit(), prepare(), MDB2_Driver_mysql\prepare(), MDB2_Driver_mysqli\prepare(), MDB2_Driver_oci8\prepare(), MDB2_Driver_pgsql\prepare(), rollback(), MDB2_Driver_mysql\rollback(), MDB2_Driver_mysqli\rollback(), MDB2_Driver_oci8\rollback(), MDB2_Driver_pgsql\rollback(), MDB2_Driver_mysql\setTransactionIsolation(), MDB2_Driver_mysqli\setTransactionIsolation(), MDB2_Driver_oci8\setTransactionIsolation(), MDB2_Driver_pgsql\setTransactionIsolation(), and setTransactionIsolation().

+ Here is the caller graph for this function:

◆ disconnect()

MDB2_Driver_Common::disconnect (   $force = true)

Log out and disconnect from the database.

Parameters
boolif the disconnect should be forced even if the connection is opened persistently
Returns
mixed true on success, false if not connected and error object on error

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2247 of file MDB2.php.

2248 {
2249 $this->connection = 0;
2250 $this->connected_dsn = array();
2251 $this->connected_database_name = '';
2252 $this->opened_persistent = null;
2253 $this->connected_server_info = '';
2254 $this->in_transaction = null;
2255 $this->nested_transaction_counter = null;
2256 return MDB2_OK;
2257 }

References MDB2_OK.

Referenced by __destruct(), setDatabase(), and setDSN().

+ Here is the caller graph for this function:

◆ errorInfo()

MDB2_Driver_Common::errorInfo (   $error = null)

This method is used to collect information about an error.

Parameters
mixederror code or resource
Returns
array with MDB2 errorcode, native error code, native message

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 1381 of file MDB2.php.

1382 {
1383 return array($error, null, null);
1384 }
$error
Definition: Error.php:17

References $error.

Referenced by raiseError().

+ Here is the caller graph for this function:

◆ escape()

MDB2_Driver_Common::escape (   $text,
  $escape_wildcards = false 
)

Quotes a string so it can be safely used in a query.

It will quote the text so it can safely be used within a query.

Parameters
stringthe input string to quote
boolescape wildcards
Returns
string quoted string

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, and MDB2_Driver_pgsql.

Definition at line 1636 of file MDB2.php.

1637 {
1638 if ($escape_wildcards) {
1639 $text = $this->escapePattern($text);
1640 }
1641
1642 $text = str_replace($this->string_quoting['end'], $this->string_quoting['escape'] . $this->string_quoting['end'], $text);
1643 return $text;
1644 }
escapePattern($text)
Quotes pattern (% and _) characters in a string)
Definition: MDB2.php:1663
$text
Definition: errorreport.php:18

References $text, and escapePattern().

+ Here is the call graph for this function:

◆ escapePattern()

MDB2_Driver_Common::escapePattern (   $text)

Quotes pattern (% and _) characters in a string)

EXPERIMENTAL

WARNING: this function is experimental and may change signature at any time until labelled as non-experimental

Parameters
stringthe input string to quote
Returns
string quoted string

@access public

Definition at line 1663 of file MDB2.php.

1664 {
1665 if ($this->string_quoting['escape_pattern']) {
1666 $text = str_replace($this->string_quoting['escape_pattern'], $this->string_quoting['escape_pattern'] . $this->string_quoting['escape_pattern'], $text);
1667 foreach ($this->wildcards as $wildcard) {
1668 $text = str_replace($wildcard, $this->string_quoting['escape_pattern'] . $wildcard, $text);
1669 }
1670 }
1671 return $text;
1672 }

References $text.

Referenced by escape(), MDB2_Driver_mysql\escape(), MDB2_Driver_mysqli\escape(), and MDB2_Driver_pgsql\escape().

+ Here is the caller graph for this function:

◆ exec()

& MDB2_Driver_Common::exec (   $query)

Execute a manipulation query to the database and return the number of affected rows.

Parameters
stringthe SQL query
Returns
mixed number of affected rows on success, a MDB2 error on failure

@access public

Definition at line 2476 of file MDB2.php.

2477 {
2480 $this->offset = $this->limit = 0;
2481 $query = $this->_modifyQuery($query, true, $limit, $offset);
2482
2483 $connection = $this->getConnection();
2485 return $connection;
2486 }
2487
2488 $result =& $this->_doQuery($query, true, $connection, $this->database_name);
2489 if (PEAR::isError($result)) {
2490 return $result;
2491 }
2492
2493 $affectedRows = $this->_affectedRows($connection, $result);
2494 return $affectedRows;
2495 }
getConnection()
Returns a native connection.
Definition: MDB2.php:1744
_affectedRows($connection, $result=null)
Returns the number of rows affected.
Definition: MDB2.php:2458
& _doQuery($query, $is_manip=false, $connection=null, $database_name=null)
Execute a query.
Definition: MDB2.php:2430
_modifyQuery($query, $is_manip, $limit, $offset)
Changes a query string for various DBMS specific reasons.
Definition: MDB2.php:2411

References $connection, $limit, $offset, $query, $result, _affectedRows(), _doQuery(), _modifyQuery(), getConnection(), and PEAR\isError().

+ Here is the call graph for this function:

◆ failNestedTransaction()

MDB2_Driver_Common::failNestedTransaction (   $error = null,
  $immediately = false 
)

Force setting nested transaction to failed.

EXPERIMENTAL

WARNING: this function is experimental and may change signature at any time until labelled as non-experimental

Parameters
mixedvalue to return in getNestededTransactionError()
boolif the transaction should be rolled back immediately
Returns
bool MDB2_OK

@access public

Since
2.1.1

Definition at line 2167 of file MDB2.php.

2168 {
2169 if (is_null($error)) {
2170 $error = $this->has_transaction_error ? $this->has_transaction_error : true;
2171 } elseif (!$error) {
2172 $error = true;
2173 }
2174 $this->has_transaction_error = $error;
2175 if (!$immediately) {
2176 return MDB2_OK;
2177 }
2178 return $this->rollback();
2179 }

References $error, MDB2_OK, and rollback().

+ Here is the call graph for this function:

◆ free()

MDB2_Driver_Common::free ( )

Free the internal references so that the instance can be destroyed.

Returns
bool true on success, false if result is invalid

@access public

Definition at line 1342 of file MDB2.php.

1343 {
1344 unset($GLOBALS['_MDB2_databases'][$this->db_index]);
1345 unset($this->db_index);
1346 return MDB2_OK;
1347 }

References $GLOBALS, and MDB2_OK.

◆ getAsKeyword()

MDB2_Driver_Common::getAsKeyword ( )

Gets the string to alias column.

Returns
string to use when aliasing a column

Definition at line 1728 of file MDB2.php.

1729 {
1730 return $this->as_keyword;
1731 }

References $as_keyword.

◆ getConnection()

◆ getDatabase()

MDB2_Driver_Common::getDatabase ( )

Get the current database.

Returns
string name of the database

@access public

Definition at line 2289 of file MDB2.php.

2290 {
2291 return $this->database_name;
2292 }

References $database_name.

◆ getDebugOutput()

MDB2_Driver_Common::getDebugOutput ( )

output debug info

Returns
string content of the debug_output class variable

@access public

Definition at line 1617 of file MDB2.php.

1618 {
1619 return $this->debug_output;
1620 }

References $debug_output.

◆ getDeclaration()

MDB2_Driver_Common::getDeclaration (   $type,
  $name,
  $field 
)

Obtain DBMS specific SQL code portion needed to declare of the given type.

Parameters
stringtype to which the value should be converted to
stringname the field to be declared.
stringdefinition of the field
Returns
string DBMS specific SQL code portion that should be used to declare the specified field.

@access public

Definition at line 3046 of file MDB2.php.

3047 {
3048 $result = $this->loadModule('Datatype', null, true);
3049 if (PEAR::isError($result)) {
3050 return $result;
3051 }
3052 return $this->datatype->getDeclaration($type, $name, $field);
3053 }
if($format !==null) $name
Definition: metadata.php:146
$type

References $name, $result, $type, PEAR\isError(), and loadModule().

+ Here is the call graph for this function:

◆ getDSN()

MDB2_Driver_Common::getDSN (   $type = 'string',
  $hidepw = false 
)

return the DSN as a string

Parameters
stringformat to return ("array", "string")
stringstring to hide the password with
Returns
mixed DSN in the chosen type

@access public

Definition at line 2331 of file MDB2.php.

2332 {
2333 $dsn = array_merge($GLOBALS['_MDB2_dsninfo_default'], $this->dsn);
2334 $dsn['phptype'] = $this->phptype;
2335 $dsn['database'] = $this->database_name;
2336 if ($hidepw) {
2337 $dsn['password'] = $hidepw;
2338 }
2339 switch ($type) {
2340 // expand to include all possible options
2341 case 'string':
2342 $dsn = $dsn['phptype'].
2343 ($dsn['dbsyntax'] ? ('('.$dsn['dbsyntax'].')') : '').
2344 '://'.$dsn['username'].':'.
2345 $dsn['password'].'@'.$dsn['hostspec'].
2346 ($dsn['port'] ? (':'.$dsn['port']) : '').
2347 '/'.$dsn['database'];
2348 break;
2349 case 'array':
2350 default:
2351 break;
2352 }
2353 return $dsn;
2354 }

References $database_name, $dsn, $GLOBALS, $phptype, and $type.

◆ getIndexName()

MDB2_Driver_Common::getIndexName (   $idx)

adds index name formatting to a index name

Parameters
stringname of the index
Returns
string formatted index name

@access public

Definition at line 3131 of file MDB2.php.

3132 {
3133 return sprintf($this->options['idxname_format'],
3134 preg_replace('/[^a-z0-9_\$]/i', '_', $idx));
3135 }

References sprintf.

◆ getNestedTransactionError()

MDB2_Driver_Common::getNestedTransactionError ( )

The first error that occured since the transaction start.

EXPERIMENTAL

WARNING: this function is experimental and may change signature at any time until labelled as non-experimental

Returns
MDB2_Error|bool MDB2 error object if an error occured or false.

@access public

Since
2.1.1

Definition at line 2197 of file MDB2.php.

2198 {
2200 }

References $has_transaction_error.

◆ getOption()

MDB2_Driver_Common::getOption (   $option)

Returns the value of an option.

Parameters
stringoption name
Returns
mixed the option value or error object

@access public

Definition at line 1567 of file MDB2.php.

1568 {
1569 if (array_key_exists($option, $this->options)) {
1570 return $this->options[$option];
1571 }
1572 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1573 "unknown option $option", __FUNCTION__);
1574 }

References MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by MDB2_Driver_oci8\_doQuery(), and loadModule().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSequenceName()

MDB2_Driver_Common::getSequenceName (   $sqn)

adds sequence name formatting to a sequence name

Parameters
stringname of the sequence
Returns
string formatted sequence name

@access public

Reimplemented in MDB2_Driver_pgsql.

Definition at line 3113 of file MDB2.php.

3114 {
3115 return sprintf($this->options['seqname_format'],
3116 preg_replace('/[^a-z0-9_\$.]/i', '_', $sqn));
3117 }

References sprintf.

Referenced by MDB2_Driver_mysql\currID(), MDB2_Driver_mysqli\currID(), MDB2_Driver_oci8\currId(), MDB2_Driver_oci8\lastInsertID(), MDB2_Driver_mysql\nextID(), MDB2_Driver_mysqli\nextID(), and MDB2_Driver_oci8\nextID().

+ Here is the caller graph for this function:

◆ getServerVersion()

MDB2_Driver_Common::getServerVersion (   $native = false)

return version information about the server

Parameters
booldetermines if the raw version string should be returned
Returns
mixed array with version information or row string

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2623 of file MDB2.php.

2624 {
2625 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2626 'method not implemented', __FUNCTION__);
2627 }

References MDB2_ERROR_UNSUPPORTED, and raiseError().

+ Here is the call graph for this function:

◆ getWarnings()

MDB2_Driver_Common::getWarnings ( )

Get all warnings in reverse order.

This means that the last warning is the first element in the array

Returns
array with warnings

@access public

See also
resetWarnings()

Definition at line 1488 of file MDB2.php.

1489 {
1490 return array_reverse($this->warnings);
1491 }

◆ inTransaction()

MDB2_Driver_Common::inTransaction (   $ignore_nested = false)

If a transaction is currently open.

Parameters
boolif the nested transaction count should be ignored
Returns
int|bool - an integer with the nesting depth is returned if a nested transaction is open
  • true is returned for a normal open transaction
  • false is returned if no transaction is open

@access public

Definition at line 2024 of file MDB2.php.

2025 {
2026 if (!$ignore_nested && isset($this->nested_transaction_counter)) {
2028 }
2029 return $this->in_transaction;
2030 }

References $in_transaction, and $nested_transaction_counter.

◆ lastInsertID()

MDB2_Driver_Common::lastInsertID (   $table = null,
  $field = null 
)

Returns the autoincrement ID if supported or $id or fetches the current ID in a sequence called: $table.

(empty($field) ? '' : '_'.$field)

Parameters
stringname of the table into which a new row was inserted
stringname of the field into which a new row was inserted
Returns
mixed MDB2 Error Object or id

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 3170 of file MDB2.php.

3171 {
3172 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
3173 'method not implemented', __FUNCTION__);
3174 }

References MDB2_ERROR_UNSUPPORTED, and raiseError().

+ Here is the call graph for this function:

◆ loadModule()

& MDB2_Driver_Common::loadModule (   $module,
  $property = null,
  $phptype_specific = null 
)

loads a module

Parameters
stringname of the module that should be loaded (only used for error messages)
stringname of the property into which the class will be loaded
boolif the class to load for the module is specific to the phptype
Returns
object on success a reference to the given module is returned and on failure a PEAR error

@access public

Definition at line 1851 of file MDB2.php.

1852 {
1853 if (!$property) {
1854 $property = strtolower($module);
1855 }
1856
1857 if (!isset($this->{$property})) {
1858 $version = $phptype_specific;
1859 if ($phptype_specific !== false) {
1860 $version = true;
1861 $class_name = 'MDB2_Driver_'.$module.'_'.$this->phptype;
1862 $file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
1863 }
1864 if ($phptype_specific === false
1865 || (!MDB2::classExists($class_name) && !MDB2::fileExists($file_name))
1866 ) {
1867 $version = false;
1868 $class_name = 'MDB2_'.$module;
1869 $file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
1870 }
1871
1872 $err = MDB2::loadClass($class_name, $this->getOption('debug'));
1873 if (PEAR::isError($err)) {
1874 return $err;
1875 }
1876
1877 // load modul in a specific version
1878 if ($version) {
1879 if (method_exists($class_name, 'getClassName')) {
1880 $class_name_new = call_user_func(array($class_name, 'getClassName'), $this->db_index);
1881 if ($class_name != $class_name_new) {
1882 $class_name = $class_name_new;
1883 $err = MDB2::loadClass($class_name, $this->getOption('debug'));
1884 if (PEAR::isError($err)) {
1885 return $err;
1886 }
1887 }
1888 }
1889 }
1890
1891 if (!MDB2::classExists($class_name)) {
1892 $err =& $this->raiseError(MDB2_ERROR_LOADMODULE, null, null,
1893 "unable to load module '$module' into property '$property'", __FUNCTION__);
1894 return $err;
1895 }
1896 $this->{$property} = new $class_name($this->db_index);
1897 $this->modules[$module] =& $this->{$property};
1898 if ($version) {
1899 // this will be used in the connect method to determine if the module
1900 // needs to be loaded with a different version if the server
1901 // version changed in between connects
1902 $this->loaded_version_modules[] = $property;
1903 }
1904 }
1905
1906 return $this->{$property};
1907 }
const MDB2_ERROR_LOADMODULE
Definition: MDB2.php:106
getOption($option)
Returns the value of an option.
Definition: MDB2.php:1567
fileExists($file)
Checks if a file exists in the include path.
Definition: MDB2.php:926
loadClass($class_name, $debug)
Loads a PEAR class.
Definition: MDB2.php:330

References $module, $phptype, $version, MDB2\classExists(), MDB2\fileExists(), getOption(), PEAR\isError(), MDB2\loadClass(), MDB2_ERROR_LOADMODULE, and raiseError().

Referenced by __call(), _wrapResult(), compareDefinition(), getDeclaration(), MDB2_Driver_mysql\nextID(), MDB2_Driver_mysqli\nextID(), MDB2_Driver_oci8\nextID(), MDB2_Driver_pgsql\nextID(), MDB2_Driver_pgsql\prepare(), quote(), and subSelect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MDB2_Driver_Common()

MDB2_Driver_Common::MDB2_Driver_Common ( )

PHP 4 Constructor.

Definition at line 1315 of file MDB2.php.

1316 {
1317 $this->destructor_registered = false;
1318 $this->__construct();
1319 }
__construct()
Constructor.
Definition: MDB2.php:1301

References __construct().

+ Here is the call graph for this function:

◆ nextID()

MDB2_Driver_Common::nextID (   $seq_name,
  $ondemand = true 
)

Returns the next free id of a sequence.

Parameters
stringname of the sequence
boolwhen true missing sequences are automatic created
Returns
mixed MDB2 Error Object or id

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 3150 of file MDB2.php.

3151 {
3152 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
3153 'method not implemented', __FUNCTION__);
3154 }

References MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by currID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepare()

& MDB2_Driver_Common::prepare (   $query,
  $types = null,
  $result_types = null,
  $lobs = array() 
)

Prepares a query for multiple execution with execute().

With some database backends, this is emulated. prepare() requires a generic query as string like 'INSERT INTO numbers VALUES(?,?)' or 'INSERT INTO numbers VALUES(:foo,:bar)'. The ? and :[a-zA-Z] and are placeholders which can be set using bindParam() and the query can be send off using the execute() method.

Parameters
stringthe query to prepare
mixedarray that contains the types of the placeholders
mixedarray that contains the types of the columns in the result set or MDB2_PREPARE_RESULT, if set to MDB2_PREPARE_MANIP the query is handled as a manipulation query
mixedkey (field) value (parameter) pair for all lob placeholders
Returns
mixed resource handle for the prepared query on success, a MDB2 error on failure

@access public

See also
bindParam, execute

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2866 of file MDB2.php.

2867 {
2868 $is_manip = ($result_types === MDB2_PREPARE_MANIP);
2871 $this->offset = $this->limit = 0;
2872 $result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre'));
2873 if ($result) {
2874 if (PEAR::isError($result)) {
2875 return $result;
2876 }
2877 $query = $result;
2878 }
2879 $placeholder_type_guess = $placeholder_type = null;
2880 $question = '?';
2881 $colon = ':';
2882 $positions = array();
2883 $position = 0;
2884 $ignores = $this->sql_comments;
2885 $ignores[] = $this->string_quoting;
2886 $ignores[] = $this->identifier_quoting;
2887 while ($position < strlen($query)) {
2888 $q_position = strpos($query, $question, $position);
2889 $c_position = strpos($query, $colon, $position);
2890 if ($q_position && $c_position) {
2891 $p_position = min($q_position, $c_position);
2892 } elseif ($q_position) {
2893 $p_position = $q_position;
2894 } elseif ($c_position) {
2895 $p_position = $c_position;
2896 } else {
2897 break;
2898 }
2899 if (is_null($placeholder_type)) {
2900 $placeholder_type_guess = $query[$p_position];
2901 }
2902
2903 $new_pos = $this->_skipDelimitedStrings($query, $position, $p_position);
2904 if (PEAR::isError($new_pos)) {
2905 return $new_pos;
2906 }
2907 if ($new_pos != $position) {
2908 $position = $new_pos;
2909 continue; //evaluate again starting from the new position
2910 }
2911
2912 if ($query[$position] == $placeholder_type_guess) {
2913 if (is_null($placeholder_type)) {
2914 $placeholder_type = $query[$p_position];
2915 $question = $colon = $placeholder_type;
2916 if (!empty($types) && is_array($types)) {
2917 if ($placeholder_type == ':') {
2918 if (is_int(key($types))) {
2919 $types_tmp = $types;
2920 $types = array();
2921 $count = -1;
2922 }
2923 } else {
2924 $types = array_values($types);
2925 }
2926 }
2927 }
2928 if ($placeholder_type == ':') {
2929 $parameter = preg_replace('/^.{'.($position+1).'}([a-z0-9_]+).*$/si', '\\1', $query);
2930 if ($parameter === '') {
2931 $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
2932 'named parameter with an empty name', __FUNCTION__);
2933 return $err;
2934 }
2935 $positions[$p_position] = $parameter;
2936 $query = substr_replace($query, '?', $position, strlen($parameter)+1);
2937 // use parameter name in type array
2938 if (isset($count) && isset($types_tmp[++$count])) {
2939 $types[$parameter] = $types_tmp[$count];
2940 }
2941 } else {
2942 $positions[$p_position] = count($positions);
2943 }
2944 $position = $p_position + 1;
2945 } else {
2946 $position = $p_position;
2947 }
2948 }
2949 $class_name = 'MDB2_Statement_'.$this->phptype;
2950 $statement = null;
2951 $obj = new $class_name($this, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset);
2952 $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'post', 'result' => $obj));
2953 return $obj;
2954 }
const MDB2_PREPARE_MANIP
These are just helper constants to more verbosely express parameters to prepare()
Definition: MDB2.php:114
_skipDelimitedStrings($query, $position, $p_position)
Utility method, used by prepare() to avoid replacing placeholders within delimited strings.
Definition: MDB2.php:2974

References $identifier_quoting, $limit, $offset, $query, $result, $sql_comments, $string_quoting, _skipDelimitedStrings(), debug(), PEAR\isError(), MDB2_ERROR_SYNTAX, MDB2_PREPARE_MANIP, and raiseError().

+ Here is the call graph for this function:

◆ query()

& MDB2_Driver_Common::query (   $query,
  $types = null,
  $result_class = true,
  $result_wrap_class = false 
)

Send a query to the database and return any results.

Parameters
stringthe SQL query
mixedarray that contains the types of the columns in the result set
mixedstring which specifies which result class to use
mixedstring which specifies which class to wrap results in
Returns
mixed an MDB2_Result handle on success, a MDB2 error on failure

@access public

Definition at line 2513 of file MDB2.php.

2514 {
2517 $this->offset = $this->limit = 0;
2518 $query = $this->_modifyQuery($query, false, $limit, $offset);
2519
2520 $connection = $this->getConnection();
2522 return $connection;
2523 }
2524
2525 $result =& $this->_doQuery($query, false, $connection, $this->database_name);
2526 if (PEAR::isError($result)) {
2527 return $result;
2528 }
2529
2530 $result =& $this->_wrapResult($result, $types, $result_class, $result_wrap_class, $limit, $offset);
2531 return $result;
2532 }
& _wrapResult($result, $types=array(), $result_class=true, $result_wrap_class=false, $limit=null, $offset=null)
wrap a result set into the correct class
Definition: MDB2.php:2552

References $connection, $limit, $offset, $query, $result, _doQuery(), _modifyQuery(), _wrapResult(), getConnection(), and PEAR\isError().

Referenced by queryAll(), queryCol(), queryOne(), and queryRow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queryAll()

MDB2_Driver_Common::queryAll (   $query,
  $types = null,
  $fetchmode = MDB2_FETCHMODE_DEFAULT,
  $rekey = false,
  $force_array = false,
  $group = false 
)

Execute the specified query, fetch all the rows of the result set into a two dimensional array and then frees the result set.

Parameters
stringthe SELECT query statement to be executed.
arrayoptional array argument that specifies a list of expected datatypes of the result set columns, so that the eventual conversions may be performed. The default list of datatypes is empty, meaning that no conversion is performed.
inthow the array data should be indexed
boolif set to true, the $all will have the first column as its first dimension
boolused only when the query returns exactly two columns. If true, the values of the returned array will be one-element arrays instead of scalars.
boolif true, the values of the returned array is wrapped in another array. If the same key value (in the first column) repeats itself, the values will be appended to this array instead of overwriting the existing values.
Returns
mixed MDB2_OK or data array on success, a MDB2 error on failure

@access public

Definition at line 3314 of file MDB2.php.

3316 {
3317 $result = $this->query($query, $types);
3319 return $result;
3320 }
3321
3322 $all = $result->fetchAll($fetchmode, $rekey, $force_array, $group);
3323 $result->free();
3324 return $all;
3325 }
& query($query, $types=null, $result_class=true, $result_wrap_class=false)
Send a query to the database and return any results.
Definition: MDB2.php:2513

References $fetchmode, $query, $result, MDB2\isResultCommon(), and query().

+ Here is the call graph for this function:

◆ queryCol()

MDB2_Driver_Common::queryCol (   $query,
  $type = null,
  $colnum = 0 
)

Execute the specified query, fetch the value from the first column of each row of the result set into an array and then frees the result set.

Parameters
stringthe SELECT query statement to be executed.
stringoptional argument that specifies the expected datatype of the result set field, so that an eventual conversion may be performed. The default datatype is text, meaning that no conversion is performed
intthe row number to fetch
Returns
mixed MDB2_OK or data array on success, a MDB2 error on failure

@access public

Definition at line 3275 of file MDB2.php.

3276 {
3277 $result = $this->query($query, $type);
3279 return $result;
3280 }
3281
3282 $col = $result->fetchCol($colnum);
3283 $result->free();
3284 return $col;
3285 }

References $query, $result, $type, MDB2\isResultCommon(), and query().

Referenced by subSelect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queryOne()

MDB2_Driver_Common::queryOne (   $query,
  $type = null,
  $colnum = 0 
)

Execute the specified query, fetch the value from the first column of the first row of the result set and then frees the result set.

Parameters
stringthe SELECT query statement to be executed.
stringoptional argument that specifies the expected datatype of the result set field, so that an eventual conversion may be performed. The default datatype is text, meaning that no conversion is performed
intthe column number to fetch
Returns
mixed MDB2_OK or field value on success, a MDB2 error on failure

@access public

Definition at line 3214 of file MDB2.php.

3215 {
3216 $result = $this->query($query, $type);
3218 return $result;
3219 }
3220
3221 $one = $result->fetchOne($colnum);
3222 $result->free();
3223 return $one;
3224 }

References $query, $result, $type, MDB2\isResultCommon(), and query().

Referenced by MDB2_Driver_mysql\currID(), MDB2_Driver_mysqli\currID(), MDB2_Driver_oci8\currId(), MDB2_Driver_pgsql\currID(), MDB2_Driver_pgsql\getSequenceName(), MDB2_Driver_pgsql\getServerVersion(), MDB2_Driver_mysql\lastInsertID(), MDB2_Driver_mysqli\lastInsertID(), MDB2_Driver_oci8\lastInsertID(), MDB2_Driver_pgsql\lastInsertID(), MDB2_Driver_oci8\nextID(), and MDB2_Driver_pgsql\nextID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queryRow()

MDB2_Driver_Common::queryRow (   $query,
  $types = null,
  $fetchmode = MDB2_FETCHMODE_DEFAULT 
)

Execute the specified query, fetch the values from the first row of the result set into an array and then frees the result set.

Parameters
stringthe SELECT query statement to be executed.
arrayoptional array argument that specifies a list of expected datatypes of the result set columns, so that the eventual conversions may be performed. The default list of datatypes is empty, meaning that no conversion is performed.
inthow the array data should be indexed
Returns
mixed MDB2_OK or data array on success, a MDB2 error on failure

@access public

Definition at line 3245 of file MDB2.php.

3246 {
3247 $result = $this->query($query, $types);
3249 return $result;
3250 }
3251
3252 $row = $result->fetchRow($fetchmode);
3253 $result->free();
3254 return $row;
3255 }

References $fetchmode, $query, $result, $row, MDB2\isResultCommon(), and query().

+ Here is the call graph for this function:

◆ quote()

MDB2_Driver_Common::quote (   $value,
  $type = null,
  $quote = true,
  $escape_wildcards = false 
)

Convert a text value into a DBMS specific format that is suitable to compose query statements.

Parameters
stringtext string value that is intended to be converted.
stringtype to which the value should be converted to
boolquote
boolescape wildcards
Returns
string text string that represents the given argument value in a DBMS specific format.

@access public

Definition at line 3020 of file MDB2.php.

3021 {
3022 $result = $this->loadModule('Datatype', null, true);
3023 if (PEAR::isError($result)) {
3024 return $result;
3025 }
3026
3027 return $this->datatype->quote($value, $type, $quote, $escape_wildcards);
3028 }

References $result, $type, PEAR\isError(), and loadModule().

Referenced by MDB2_Driver_pgsql\getSequenceName(), MDB2_Driver_oci8\prepare(), replace(), MDB2_Driver_mysql\replace(), and MDB2_Driver_mysqli\replace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quoteIdentifier()

MDB2_Driver_Common::quoteIdentifier (   $str,
  $check_option = false 
)

Quote a string so it can be safely used as a table or column name.

Delimiting style depends on which database driver is being used.

NOTE: just because you CAN use delimited identifiers doesn't mean you SHOULD use them. In general, they end up causing way more problems than they solve.

Portability is broken by using the following characters inside delimited identifiers:

  • backtick (`) – due to MySQL
  • double quote (") – due to Oracle
  • brackets ([ or ]) – due to Access

Delimited identifiers are known to generally work correctly under the following drivers:

  • mssql
  • mysql
  • mysqli
  • oci8
  • pgsql
  • sqlite

InterBase doesn't seem to be able to use delimited identifiers via PHP 4. They work fine under PHP 5.

Parameters
stringidentifier name to be quoted
boolcheck the 'quote_identifier' option
Returns
string quoted identifier string

@access public

Definition at line 1711 of file MDB2.php.

1712 {
1713 if ($check_option && !$this->options['quote_identifier']) {
1714 return $str;
1715 }
1716 $str = str_replace($this->identifier_quoting['end'], $this->identifier_quoting['escape'] . $this->identifier_quoting['end'], $str);
1717 return $this->identifier_quoting['start'] . $str . $this->identifier_quoting['end'];
1718 }

Referenced by MDB2_Driver_mysql\currID(), MDB2_Driver_mysqli\currID(), MDB2_Driver_pgsql\currID(), MDB2_Driver_oci8\lastInsertID(), MDB2_Driver_mysql\nextID(), MDB2_Driver_mysqli\nextID(), MDB2_Driver_oci8\nextID(), and MDB2_Driver_pgsql\nextID().

+ Here is the caller graph for this function:

◆ raiseError()

& MDB2_Driver_Common::raiseError (   $message = null,
  $code = null,
  $mode = null,
  $options = null,
  $userinfo = null,
  $error_class = null,
  $skipmsg = false 
)

This method is used to communicate an error and invoke error callbacks etc.

Basically a wrapper for PEAR::raiseError without the message string.

Parameters
mixedinteger error code, or a PEAR error object (all other parameters are ignored if this parameter is an object
interror mode, see PEAR_Error docs
mixedIf error mode is PEAR_ERROR_TRIGGER, this is the error level (E_USER_NOTICE etc). If error mode is PEAR_ERROR_CALLBACK, this is the callback function, either as a function name, or as an array of an object and method name. For other error modes this parameter is ignored.
stringExtra debug information. Defaults to the last query and native error code.
stringname of the method that triggered the error
Returns
PEAR_Error instance of a PEAR Error object

@access public

See also
PEAR_Error

Reimplemented from PEAR.

Definition at line 1412 of file MDB2.php.

1419 {
1420 $userinfo = "[Error message: $userinfo]\n";
1421 // The error is yet a MDB2 error object
1422 if (PEAR::isError($code)) {
1423 // because we use the static PEAR::raiseError, our global
1424 // handler should be used if it is set
1425 if (is_null($mode) && !empty($this->_default_error_mode)) {
1428 }
1429 if (is_null($userinfo)) {
1430 $userinfo = $code->getUserinfo();
1431 }
1432 $code = $code->getCode();
1433 } elseif ($code == MDB2_ERROR_NOT_FOUND) {
1434 // extension not loaded: don't call $this->errorInfo() or the script
1435 // will die
1436 } elseif (isset($this->connection)) {
1437 if (!empty($this->last_query)) {
1438 $userinfo.= "[Last executed query: {$this->last_query}]\n";
1439 }
1440 $native_errno = $native_msg = null;
1441 list($code, $native_errno, $native_msg) = $this->errorInfo($code);
1442 if (!is_null($native_errno) && $native_errno !== '') {
1443 $userinfo.= "[Native code: $native_errno]\n";
1444 }
1445 if (!is_null($native_msg) && $native_msg !== '') {
1446 $userinfo.= "[Native message: ". strip_tags($native_msg) ."]\n";
1447 }
1448 if (!is_null($method)) {
1449 $userinfo = $method.': '.$userinfo;
1450 }
1451 }
1452
1453 $err =& PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
1454 if ($err->getMode() !== PEAR_ERROR_RETURN
1455 && isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
1456 $this->has_transaction_error =& $err;
1457 }
1458 return $err;
1459 }
const PEAR_ERROR_RETURN
#+ ERROR constants
Definition: PEAR.php:31
errorInfo($error=null)
This method is used to collect information about an error.
Definition: MDB2.php:1381
$_default_error_mode
Definition: PEAR.php:120
$_default_error_options
Definition: PEAR.php:129
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is a wrapper that returns an instance of the configured error class with this object's de...
Definition: PEAR.php:522
$code
Definition: example_050.php:99

References PEAR\$_default_error_mode, PEAR\$_default_error_options, $code, $options, errorInfo(), PEAR\isError(), MDB2_ERROR_NOT_FOUND, PEAR_ERROR_RETURN, and PEAR\raiseError().

Referenced by _affectedRows(), MDB2_Driver_pgsql\_doConnect(), MDB2_Driver_oci8\_doConnect(), _doQuery(), MDB2_Driver_mysql\_doQuery(), MDB2_Driver_mysqli\_doQuery(), MDB2_Driver_oci8\_doQuery(), MDB2_Driver_pgsql\_doQuery(), _skipDelimitedStrings(), _wrapResult(), beginTransaction(), MDB2_Driver_mysql\beginTransaction(), MDB2_Driver_mysqli\beginTransaction(), MDB2_Driver_oci8\beginTransaction(), MDB2_Driver_pgsql\beginTransaction(), commit(), MDB2_Driver_mysql\commit(), MDB2_Driver_mysqli\commit(), MDB2_Driver_oci8\commit(), MDB2_Driver_pgsql\commit(), connect(), MDB2_Driver_mysql\connect(), MDB2_Driver_mysqli\connect(), MDB2_Driver_pgsql\connect(), getOption(), getServerVersion(), MDB2_Driver_mysql\getServerVersion(), MDB2_Driver_mysqli\getServerVersion(), MDB2_Driver_oci8\getServerVersion(), lastInsertID(), loadModule(), nextID(), MDB2_Driver_mysql\nextID(), MDB2_Driver_mysqli\nextID(), MDB2_Driver_pgsql\nextID(), prepare(), MDB2_Driver_mysql\prepare(), MDB2_Driver_mysqli\prepare(), MDB2_Driver_oci8\prepare(), MDB2_Driver_pgsql\prepare(), replace(), MDB2_Driver_mysql\replace(), MDB2_Driver_mysqli\replace(), rollback(), MDB2_Driver_mysql\rollback(), MDB2_Driver_mysqli\rollback(), MDB2_Driver_oci8\rollback(), MDB2_Driver_pgsql\rollback(), setCharset(), MDB2_Driver_pgsql\setCharset(), setFetchMode(), setLimit(), setOption(), MDB2_Driver_mysql\setTransactionIsolation(), MDB2_Driver_mysqli\setTransactionIsolation(), MDB2_Driver_oci8\setTransactionIsolation(), MDB2_Driver_pgsql\setTransactionIsolation(), setTransactionIsolation(), MDB2_Driver_pgsql\standaloneQuery(), subSelect(), and supports().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replace()

MDB2_Driver_Common::replace (   $table,
  $fields 
)

Execute a SQL REPLACE query.

A REPLACE query is identical to a INSERT query, except that if there is already a row in the table with the same key field values, the REPLACE query just updates its values instead of inserting a new row.

The REPLACE type of query does not make part of the SQL standards. Since practically only MySQL and SQLite implement it natively, this type of query isemulated through this method for other DBMS using standard types of queries inside a transaction to assure the atomicity of the operation.

Parameters
stringname of the table on which the REPLACE query will be executed.
arrayassociative array that describes the fields and the values that will be inserted or updated in the specified table. The indexes of the array are the names of all the fields of the table. The values of the array are also associative arrays that describe the values and other properties of the table fields.

Here follows a list of field properties that need to be specified:

value Value to be assigned to the specified field. This value may be of specified in database independent type format as this function can perform the necessary datatype conversions.

Default: this property is required unless the Null property is set to 1.

type Name of the type of the field. Currently, all types MDB2 are supported except for clob and blob.

Default: no type conversion

null bool property that indicates that the value for this field should be set to null.

The default value for fields missing in INSERT queries may be specified the definition of a table. Often, the default value is already null, but since the REPLACE may be emulated using an UPDATE query, make sure that all fields of the table are listed in this function argument array.

Default: 0

key bool property that indicates that this field should be handled as a primary key or at least as part of the compound unique index of the table that will determine the row that will updated if it exists or inserted a new row otherwise.

This function will fail if no key field is specified or if the value of a key field is set to null because fields that are part of unique index they may not be null.

Default: 0

Returns
mixed MDB2_OK on success, a MDB2 error on failure

@access public

Reimplemented in MDB2_Driver_mysql, and MDB2_Driver_mysqli.

Definition at line 2771 of file MDB2.php.

2772 {
2773 if (!$this->supports('replace')) {
2774 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2775 'replace query is not supported', __FUNCTION__);
2776 }
2777 $count = count($fields);
2778 $condition = $values = array();
2779 for ($colnum = 0, reset($fields); $colnum < $count; next($fields), $colnum++) {
2780 $name = key($fields);
2781 if (isset($fields[$name]['null']) && $fields[$name]['null']) {
2782 $value = 'NULL';
2783 } else {
2784 $type = isset($fields[$name]['type']) ? $fields[$name]['type'] : null;
2785 $value = $this->quote($fields[$name]['value'], $type);
2786 }
2787 $values[$name] = $value;
2788 if (isset($fields[$name]['key']) && $fields[$name]['key']) {
2789 if ($value === 'NULL') {
2790 return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null,
2791 'key value '.$name.' may not be NULL', __FUNCTION__);
2792 }
2793 $condition[] = $name . '=' . $value;
2794 }
2795 }
2796 if (empty($condition)) {
2797 return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null,
2798 'not specified which fields are keys', __FUNCTION__);
2799 }
2800
2801 $result = null;
2804 return $result;
2805 }
2806
2807 $connection = $this->getConnection();
2809 return $connection;
2810 }
2811
2812 $condition = ' WHERE '.implode(' AND ', $condition);
2813 $query = "DELETE FROM $table$condition";
2814 $result =& $this->_doQuery($query, true, $connection);
2815 if (!PEAR::isError($result)) {
2816 $affected_rows = $this->_affectedRows($connection, $result);
2817 $insert = implode(', ', array_keys($values));
2818 $values = implode(', ', $values);
2819 $query = "INSERT INTO $table ($insert) VALUES ($values)";
2820 $result =& $this->_doQuery($query, true, $connection);
2821 if (!PEAR::isError($result)) {
2822 $affected_rows += $this->_affectedRows($connection, $result);;
2823 }
2824 }
2825
2826 if (!$in_transaction) {
2827 if (PEAR::isError($result)) {
2828 $this->rollback();
2829 } else {
2830 $result = $this->commit();
2831 }
2832 }
2833
2834 if (PEAR::isError($result)) {
2835 return $result;
2836 }
2837
2838 return $affected_rows;
2839 }
const MDB2_ERROR_CANNOT_REPLACE
Definition: MDB2.php:100
quote($value, $type=null, $quote=true, $escape_wildcards=false)
Convert a text value into a DBMS specific format that is suitable to compose query statements.
Definition: MDB2.php:3020
$insert

References $connection, $in_transaction, $insert, $name, $query, $result, $type, _affectedRows(), _doQuery(), beginTransaction(), commit(), getConnection(), PEAR\isError(), MDB2_ERROR_CANNOT_REPLACE, MDB2_ERROR_UNSUPPORTED, quote(), raiseError(), rollback(), and supports().

+ Here is the call graph for this function:

◆ resetWarnings()

MDB2_Driver_Common::resetWarnings ( )

reset the warning array

Returns
void

@access public

Definition at line 1471 of file MDB2.php.

1472 {
1473 $this->warnings = array();
1474 }

◆ rollback()

MDB2_Driver_Common::rollback (   $savepoint = null)

Cancel any database changes done during a transaction or since a specific savepoint that is in progress.

This function may only be called when auto-committing is disabled, otherwise it will fail. Therefore, a new transaction is implicitly started after canceling the pending changes.

Parameters
stringname of a savepoint to rollback to
Returns
mixed MDB2_OK on success, a MDB2 error on failure

@access public

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2003 of file MDB2.php.

2004 {
2005 $this->debug('Rolling back transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
2006 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2007 'rolling back transactions is not supported', __FUNCTION__);
2008 }

References debug(), MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by completeNestedTransaction(), failNestedTransaction(), and replace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCharset()

MDB2_Driver_Common::setCharset (   $charset,
  $connection = null 
)

Set the charset on the current connection.

Parameters
stringcharset
resourceconnection handle
Returns
true on success, MDB2 Error Object on failure

Reimplemented in MDB2_Driver_mysql, MDB2_Driver_mysqli, and MDB2_Driver_pgsql.

Definition at line 2227 of file MDB2.php.

2228 {
2229 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2230 'method not implemented', __FUNCTION__);
2231 }

References MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by MDB2_Driver_oci8\_doConnect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDatabase()

MDB2_Driver_Common::setDatabase (   $name)

Select a different database.

Parameters
stringname of the database that should be selected
Returns
string name of the database previously connected to

@access public

Definition at line 2271 of file MDB2.php.

2272 {
2273 $previous_database_name = (isset($this->database_name)) ? $this->database_name : '';
2274 $this->database_name = $name;
2275 $this->disconnect(false);
2276 return $previous_database_name;
2277 }

References $name, and disconnect().

+ Here is the call graph for this function:

◆ setDSN()

MDB2_Driver_Common::setDSN (   $dsn)

set the DSN

Parameters
mixedDSN string or array
Returns
MDB2_OK

@access public

Definition at line 2306 of file MDB2.php.

2307 {
2308 $dsn_default = $GLOBALS['_MDB2_dsninfo_default'];
2310 if (array_key_exists('database', $dsn)) {
2311 $this->database_name = $dsn['database'];
2312 unset($dsn['database']);
2313 }
2314 $this->dsn = array_merge($dsn_default, $dsn);
2315 return $this->disconnect(false);
2316 }
parseDSN($dsn)
Definition: MDB2.php:796

References $dsn, $GLOBALS, disconnect(), and MDB2\parseDSN().

+ Here is the call graph for this function:

◆ setFetchMode()

MDB2_Driver_Common::setFetchMode (   $fetchmode,
  $object_class = 'stdClass' 
)

Sets which fetch mode should be used by default on queries on this connection.

Parameters
intMDB2_FETCHMODE_ORDERED, MDB2_FETCHMODE_ASSOC or MDB2_FETCHMODE_OBJECT
stringthe class name of the object to be returned by the fetch methods when the MDB2_FETCHMODE_OBJECT mode is selected. If no class is specified by default a cast to object from the assoc array row will be done. There is also the possibility to use and extend the 'MDB2_row' class.
Returns
mixed MDB2_OK or MDB2 Error Object

@access public

See also
MDB2_FETCHMODE_ORDERED, MDB2_FETCHMODE_ASSOC, MDB2_FETCHMODE_OBJECT

Definition at line 1515 of file MDB2.php.

1516 {
1517 switch ($fetchmode) {
1519 $this->options['fetch_class'] = $object_class;
1522 $this->fetchmode = $fetchmode;
1523 break;
1524 default:
1525 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1526 'invalid fetchmode mode', __FUNCTION__);
1527 }
1528
1529 return MDB2_OK;
1530 }
const MDB2_FETCHMODE_OBJECT
Column data as object properties.
Definition: MDB2.php:139
const MDB2_FETCHMODE_ORDERED
Column data indexed by numbers, ordered from 0 and up.
Definition: MDB2.php:129
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Definition: MDB2.php:134

References $fetchmode, MDB2_ERROR_UNSUPPORTED, MDB2_FETCHMODE_ASSOC, MDB2_FETCHMODE_OBJECT, MDB2_FETCHMODE_ORDERED, MDB2_OK, and raiseError().

+ Here is the call graph for this function:

◆ setLimit()

MDB2_Driver_Common::setLimit (   $limit,
  $offset = null 
)

set the range of the next query

Parameters
stringnumber of rows to select
stringfirst row to select
Returns
mixed MDB2_OK on success, a MDB2 error on failure

@access public

Definition at line 2642 of file MDB2.php.

2643 {
2644 if (!$this->supports('limit_queries')) {
2645 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2646 'limit is not supported by this driver', __FUNCTION__);
2647 }
2648 $limit = (int)$limit;
2649 if ($limit < 0) {
2650 return $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
2651 'it was not specified a valid selected range row limit', __FUNCTION__);
2652 }
2653 $this->limit = $limit;
2654 if (!is_null($offset)) {
2655 $offset = (int)$offset;
2656 if ($offset < 0) {
2657 return $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
2658 'it was not specified a valid first selected range row', __FUNCTION__);
2659 }
2660 $this->offset = $offset;
2661 }
2662 return MDB2_OK;
2663 }

References $limit, $offset, MDB2_ERROR_SYNTAX, MDB2_ERROR_UNSUPPORTED, MDB2_OK, raiseError(), and supports().

+ Here is the call graph for this function:

◆ setOption()

MDB2_Driver_Common::setOption (   $option,
  $value 
)

set the option for the db class

Parameters
stringoption name
mixedvalue for the option
Returns
mixed MDB2_OK or MDB2 Error Object

@access public

Definition at line 1545 of file MDB2.php.

1546 {
1547 if (array_key_exists($option, $this->options)) {
1548 $this->options[$option] = $value;
1549 return MDB2_OK;
1550 }
1551 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1552 "unknown option $option", __FUNCTION__);
1553 }

References MDB2_ERROR_UNSUPPORTED, MDB2_OK, and raiseError().

+ Here is the call graph for this function:

◆ setTransactionIsolation()

MDB2_Driver_Common::setTransactionIsolation (   $isolation,
  $options = array() 
)

Set the transacton isolation level.

Parameters
stringstandard isolation level READ UNCOMMITTED (allows dirty reads) READ COMMITTED (prevents dirty reads) REPEATABLE READ (prevents nonrepeatable reads) SERIALIZABLE (prevents phantom reads)
arraysome transaction options: 'wait' => 'WAIT' | 'NO WAIT' 'rw' => 'READ WRITE' | 'READ ONLY'
Returns
mixed MDB2_OK on success, a MDB2 error on failure

@access public

Since
2.1.1

Definition at line 2051 of file MDB2.php.

2052 {
2053 $this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true));
2054 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2055 'isolation level setting is not supported', __FUNCTION__);
2056 }

References debug(), MDB2_ERROR_UNSUPPORTED, and raiseError().

+ Here is the call graph for this function:

◆ standaloneQuery()

& MDB2_Driver_Common::standaloneQuery (   $query,
  $types = null,
  $is_manip = false 
)

execute a query as database administrator

Parameters
stringthe SQL query
mixedarray that contains the types of the columns in the result set
boolif the query is a manipulation query
Returns
mixed MDB2_OK on success, a MDB2 error on failure

@access public

Reimplemented in MDB2_Driver_oci8, and MDB2_Driver_pgsql.

Definition at line 2371 of file MDB2.php.

2372 {
2375 $this->offset = $this->limit = 0;
2376 $query = $this->_modifyQuery($query, $is_manip, $limit, $offset);
2377
2378 $connection = $this->getConnection();
2380 return $connection;
2381 }
2382
2383 $result =& $this->_doQuery($query, $is_manip, $connection, false);
2384 if (PEAR::isError($result)) {
2385 return $result;
2386 }
2387
2388 if ($is_manip) {
2389 $affected_rows = $this->_affectedRows($connection, $result);
2390 return $affected_rows;
2391 }
2392 $result =& $this->_wrapResult($result, $types, true, false, $limit, $offset);
2393 return $result;
2394 }

References $connection, $limit, $offset, $query, $result, _affectedRows(), _doQuery(), _modifyQuery(), _wrapResult(), getConnection(), and PEAR\isError().

+ Here is the call graph for this function:

◆ subSelect()

MDB2_Driver_Common::subSelect (   $query,
  $type = false 
)

simple subselect emulation: leaves the query untouched for all RDBMS that support subselects

Parameters
stringthe SQL query for the subselect that may only return a column
stringdetermines type of the field
Returns
string the query

@access public

Definition at line 2680 of file MDB2.php.

2681 {
2682 if ($this->supports('sub_selects') === true) {
2683 return $query;
2684 }
2685
2686 if (!$this->supports('sub_selects')) {
2687 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2688 'method not implemented', __FUNCTION__);
2689 }
2690
2691 $col = $this->queryCol($query, $type);
2692 if (PEAR::isError($col)) {
2693 return $col;
2694 }
2695 if (!is_array($col) || count($col) == 0) {
2696 return 'NULL';
2697 }
2698 if ($type) {
2699 $this->loadModule('Datatype', null, true);
2700 return $this->datatype->implodeArray($col, $type);
2701 }
2702 return implode(', ', $col);
2703 }
queryCol($query, $type=null, $colnum=0)
Execute the specified query, fetch the value from the first column of each row of the result set into...
Definition: MDB2.php:3275

References $query, $type, PEAR\isError(), loadModule(), MDB2_ERROR_UNSUPPORTED, queryCol(), raiseError(), and supports().

+ Here is the call graph for this function:

◆ supports()

MDB2_Driver_Common::supports (   $feature)

Tell whether a DB implementation or its backend extension supports a given feature.

Parameters
stringname of the feature (see the MDB2 class doc)
Returns
bool|string if this DB implementation supports a given feature false means no, true means native, 'emulated' means emulated

@access public

Definition at line 3092 of file MDB2.php.

3093 {
3094 if (array_key_exists($feature, $this->supported)) {
3095 return $this->supported[$feature];
3096 }
3097 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
3098 "unknown support feature $feature", __FUNCTION__);
3099 }

References MDB2_ERROR_UNSUPPORTED, and raiseError().

Referenced by _wrapResult(), beginNestedTransaction(), MDB2_Driver_mysql\beginTransaction(), MDB2_Driver_mysqli\beginTransaction(), MDB2_Driver_mysql\commit(), MDB2_Driver_mysqli\commit(), completeNestedTransaction(), replace(), MDB2_Driver_mysql\rollback(), MDB2_Driver_mysqli\rollback(), setLimit(), MDB2_Driver_mysql\setTransactionIsolation(), MDB2_Driver_mysqli\setTransactionIsolation(), and subSelect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $as_keyword

MDB2_Driver_Common::$as_keyword = ' AS '

Definition at line 1202 of file MDB2.php.

Referenced by getAsKeyword().

◆ $connected_database_name

MDB2_Driver_Common::$connected_database_name = ''

◆ $connected_dsn

MDB2_Driver_Common::$connected_dsn = array()

◆ $connected_server_info

MDB2_Driver_Common::$connected_server_info = ''

◆ $connection

◆ $database_name

◆ $db_index

MDB2_Driver_Common::$db_index = 0

Definition at line 1003 of file MDB2.php.

Referenced by __construct().

◆ $dbsyntax

MDB2_Driver_Common::$dbsyntax

Definition at line 1265 of file MDB2.php.

◆ $debug_output

MDB2_Driver_Common::$debug_output = ''

Definition at line 1216 of file MDB2.php.

Referenced by getDebugOutput().

◆ $destructor_registered

MDB2_Driver_Common::$destructor_registered = true

Definition at line 1293 of file MDB2.php.

◆ $dsn

◆ $fetchmode

MDB2_Driver_Common::$fetchmode = MDB2_FETCHMODE_ORDERED

Definition at line 1279 of file MDB2.php.

Referenced by queryAll(), queryRow(), and setFetchMode().

◆ $has_transaction_error

MDB2_Driver_Common::$has_transaction_error = false

Definition at line 1237 of file MDB2.php.

Referenced by getNestedTransactionError().

◆ $identifier_quoting

MDB2_Driver_Common::$identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"')

Definition at line 1178 of file MDB2.php.

Referenced by _skipDelimitedStrings(), and prepare().

◆ $in_transaction

MDB2_Driver_Common::$in_transaction = false

Definition at line 1223 of file MDB2.php.

Referenced by inTransaction(), and replace().

◆ $last_query

MDB2_Driver_Common::$last_query

Definition at line 1272 of file MDB2.php.

◆ $limit

◆ $modules

MDB2_Driver_Common::$modules = array()

Definition at line 1286 of file MDB2.php.

◆ $nested_transaction_counter

MDB2_Driver_Common::$nested_transaction_counter = null

Definition at line 1230 of file MDB2.php.

Referenced by beginNestedTransaction(), completeNestedTransaction(), and inTransaction().

◆ $offset

◆ $opened_persistent

MDB2_Driver_Common::$opened_persistent

◆ $options

MDB2_Driver_Common::$options

Definition at line 1127 of file MDB2.php.

Referenced by raiseError().

◆ $phptype

◆ $sql_comments

MDB2_Driver_Common::$sql_comments
Initial value:
= array(
array('start' => '--', 'end' => "\n", 'escape' => false),
array('start' => '/*', 'end' => '*/', 'escape' => false),
)

Definition at line 1185 of file MDB2.php.

Referenced by _skipDelimitedStrings(), and prepare().

◆ $string_quoting

MDB2_Driver_Common::$string_quoting = array('start' => "'", 'end' => "'", 'escape' => false, 'escape_pattern' => false)

Definition at line 1171 of file MDB2.php.

Referenced by _skipDelimitedStrings(), and prepare().

◆ $supported

MDB2_Driver_Common::$supported
Initial value:
= array(
'sequences' => false,
'indexes' => false,
'affected_rows' => false,
'summary_functions' => false,
'order_by_text' => false,
'transactions' => false,
'savepoints' => false,
'current_id' => false,
'limit_queries' => false,
'LOBs' => false,
'replace' => false,
'sub_selects' => false,
'auto_increment' => false,
'primary_key' => false,
'result_introspection' => false,
'prepared_statements' => false,
'identifier_quoting' => false,
'pattern_escaping' => false,
'new_link' => false,
)

Definition at line 1059 of file MDB2.php.

◆ $warnings

MDB2_Driver_Common::$warnings = array()

Definition at line 1209 of file MDB2.php.

◆ $wildcards

MDB2_Driver_Common::$wildcards = array('%', '_')

Definition at line 1195 of file MDB2.php.


The documentation for this class was generated from the following file: