ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ($code=null, $mode=null, $options=null, $userinfo=null, $method=null)
 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:2241

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 1914 of file MDB2.php.

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

References $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: example_052.php:80

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 2452 of file MDB2.php.

2453 {
2454 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2455 'method not implemented', __FUNCTION__);
2456 }
const MDB2_ERROR_UNSUPPORTED
Definition: MDB2.php:78
& raiseError($code=null, $mode=null, $options=null, $userinfo=null, $method=null)
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 2424 of file MDB2.php.

2425 {
2426 $this->last_query = $query;
2427 $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
2428 if ($result) {
2429 if (PEAR::isError($result)) {
2430 return $result;
2431 }
2432 $query = $result;
2433 }
2434 $err =& $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2435 'method not implemented', __FUNCTION__);
2436 return $err;
2437 }
debug($message, $scope='', $context=array())
set a debug message
Definition: MDB2.php:1587

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 1760 of file MDB2.php.

1761 {
1762 switch ($mode) {
1764 foreach ($row as $key => $value) {
1765 if ($value === '') {
1766 $row[$key] = null;
1767 }
1768 }
1769 break;
1771 foreach ($row as $key => $value) {
1772 if (is_string($value)) {
1773 $row[$key] = rtrim($value);
1774 }
1775 }
1776 break;
1778 $tmp_row = array();
1779 foreach ($row as $key => $value) {
1780 $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value;
1781 }
1782 $row = $tmp_row;
1783 break;
1785 foreach ($row as $key => $value) {
1786 if ($value === '') {
1787 $row[$key] = null;
1788 } elseif (is_string($value)) {
1789 $row[$key] = rtrim($value);
1790 }
1791 }
1792 break;
1794 $tmp_row = array();
1795 foreach ($row as $key => $value) {
1796 if (is_string($value)) {
1797 $value = rtrim($value);
1798 }
1799 $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value;
1800 }
1801 $row = $tmp_row;
1802 break;
1804 $tmp_row = array();
1805 foreach ($row as $key => $value) {
1806 if ($value === '') {
1807 $value = null;
1808 }
1809 $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value;
1810 }
1811 $row = $tmp_row;
1812 break;
1814 $tmp_row = array();
1815 foreach ($row as $key => $value) {
1816 if ($value === '') {
1817 $value = null;
1818 } elseif (is_string($value)) {
1819 $value = rtrim($value);
1820 }
1821 $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value;
1822 }
1823 $row = $tmp_row;
1824 break;
1825 }
1826 }
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 $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 2405 of file MDB2.php.

2406 {
2407 return $query;
2408 }

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 2968 of file MDB2.php.

2969 {
2970 $ignores = $this->sql_comments;
2971 $ignores[] = $this->string_quoting;
2972 $ignores[] = $this->identifier_quoting;
2973
2974 foreach ($ignores as $ignore) {
2975 if (!empty($ignore['start'])) {
2976 if (is_int($start_quote = strpos($query, $ignore['start'], $position)) && $start_quote < $p_position) {
2977 $end_quote = $start_quote;
2978 do {
2979 if (!is_int($end_quote = strpos($query, $ignore['end'], $end_quote + 1))) {
2980 if ($ignore['end'] === "\n") {
2981 $end_quote = strlen($query) - 1;
2982 } else {
2983 $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
2984 'query with an unterminated text string specified', __FUNCTION__);
2985 return $err;
2986 }
2987 }
2988 } while ($ignore['escape'] && $query[($end_quote - 1)] == $ignore['escape']);
2989 $position = $end_quote + 1;
2990 return $position;
2991 }
2992 }
2993 }
2994 return $position;
2995 }
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 2546 of file MDB2.php.

2548 {
2549 if ($types === true) {
2550 if ($this->supports('result_introspection')) {
2551 $this->loadModule('Reverse', null, true);
2552 $tableInfo = $this->reverse->tableInfo($result);
2553 if (PEAR::isError($tableInfo)) {
2554 return $tableInfo;
2555 }
2556 $types = array();
2557 foreach ($tableInfo as $field) {
2558 $types[] = $field['mdb2type'];
2559 }
2560 } else {
2561 $types = null;
2562 }
2563 }
2564
2565 if ($result_class === true) {
2566 $result_class = $this->options['result_buffering']
2567 ? $this->options['buffered_result_class'] : $this->options['result_class'];
2568 }
2569
2570 if ($result_class) {
2571 $class_name = sprintf($result_class, $this->phptype);
2572 if (!MDB2::classExists($class_name)) {
2573 $err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
2574 'result class does not exist '.$class_name, __FUNCTION__);
2575 return $err;
2576 }
2577 $result = new $class_name($this, $result, $limit, $offset);
2579 $err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
2580 'result class is not extended from MDB2_Result_Common', __FUNCTION__);
2581 return $err;
2582 }
2583 if (!empty($types)) {
2584 $err = $result->setResultTypes($types);
2585 if (PEAR::isError($err)) {
2586 $result->free();
2587 return $err;
2588 }
2589 }
2590 }
2591 if ($result_wrap_class === true) {
2592 $result_wrap_class = $this->options['result_wrap_class'];
2593 }
2594 if ($result_wrap_class) {
2595 if (!MDB2::classExists($result_wrap_class)) {
2596 $err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
2597 'result wrap class does not exist '.$result_wrap_class, __FUNCTION__);
2598 return $err;
2599 }
2600 $result = new $result_wrap_class($result, $this->fetchmode);
2601 }
2602 return $result;
2603 }
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:3086
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 2068 of file MDB2.php.

2069 {
2070 if ($this->in_transaction) {
2072 $savepoint = sprintf($this->options['savepoint_format'], $this->nested_transaction_counter);
2073 if ($this->supports('savepoints') && $savepoint) {
2074 return $this->beginTransaction($savepoint);
2075 }
2076 return MDB2_OK;
2077 }
2078 $this->has_transaction_error = false;
2079 $result = $this->beginTransaction();
2080 $this->nested_transaction_counter = 1;
2081 return $result;
2082 }
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:1955

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 1955 of file MDB2.php.

1956 {
1957 $this->debug('Starting transaction', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
1958 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1959 'transactions are not supported', __FUNCTION__);
1960 }

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 1976 of file MDB2.php.

1977 {
1978 $this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
1979 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1980 'commiting transactions is not supported', __FUNCTION__);
1981 }

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 3062 of file MDB2.php.

3063 {
3064 $result = $this->loadModule('Datatype', null, true);
3065 if (PEAR::isError($result)) {
3066 return $result;
3067 }
3068 return $this->datatype->compareDefinition($current, $previous);
3069 }

References $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 2104 of file MDB2.php.

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

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 2204 of file MDB2.php.

2205 {
2206 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2207 'method not implemented', __FUNCTION__);
2208 }

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 3182 of file MDB2.php.

3183 {
3184 $this->warnings[] = 'database does not support getting current
3185 sequence value, the sequence value was incremented';
3186 return $this->nextID($seq_name);
3187 }
nextID($seq_name, $ondemand=true)
Returns the next free id of a sequence.
Definition: MDB2.php:3144

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 1587 of file MDB2.php.

1588 {
1589 if ($this->options['debug'] && $this->options['debug_handler']) {
1590 if (!$this->options['debug_expanded_output']) {
1591 if (!empty($context['when']) && $context['when'] !== 'pre') {
1592 return null;
1593 }
1594 $context = empty($context['is_manip']) ? false : $context['is_manip'];
1595 }
1596 return call_user_func_array($this->options['debug_handler'], array(&$this, $scope, $message, $context));
1597 }
1598 return null;
1599 }

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 2241 of file MDB2.php.

2242 {
2243 $this->connection = 0;
2244 $this->connected_dsn = array();
2245 $this->connected_database_name = '';
2246 $this->opened_persistent = null;
2247 $this->connected_server_info = '';
2248 $this->in_transaction = null;
2249 $this->nested_transaction_counter = null;
2250 return MDB2_OK;
2251 }

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 1630 of file MDB2.php.

1631 {
1632 if ($escape_wildcards) {
1633 $text = $this->escapePattern($text);
1634 }
1635
1636 $text = str_replace($this->string_quoting['end'], $this->string_quoting['escape'] . $this->string_quoting['end'], $text);
1637 return $text;
1638 }
escapePattern($text)
Quotes pattern (% and _) characters in a string)
Definition: MDB2.php:1657
$text

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 1657 of file MDB2.php.

1658 {
1659 if ($this->string_quoting['escape_pattern']) {
1660 $text = str_replace($this->string_quoting['escape_pattern'], $this->string_quoting['escape_pattern'] . $this->string_quoting['escape_pattern'], $text);
1661 foreach ($this->wildcards as $wildcard) {
1662 $text = str_replace($wildcard, $this->string_quoting['escape_pattern'] . $wildcard, $text);
1663 }
1664 }
1665 return $text;
1666 }

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 2470 of file MDB2.php.

2471 {
2474 $this->offset = $this->limit = 0;
2475 $query = $this->_modifyQuery($query, true, $limit, $offset);
2476
2477 $connection = $this->getConnection();
2479 return $connection;
2480 }
2481
2482 $result =& $this->_doQuery($query, true, $connection, $this->database_name);
2483 if (PEAR::isError($result)) {
2484 return $result;
2485 }
2486
2487 $affectedRows = $this->_affectedRows($connection, $result);
2488 return $affectedRows;
2489 }
getConnection()
Returns a native connection.
Definition: MDB2.php:1738
_affectedRows($connection, $result=null)
Returns the number of rows affected.
Definition: MDB2.php:2452
& _doQuery($query, $is_manip=false, $connection=null, $database_name=null)
Execute a query.
Definition: MDB2.php:2424
_modifyQuery($query, $is_manip, $limit, $offset)
Changes a query string for various DBMS specific reasons.
Definition: MDB2.php:2405

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 2161 of file MDB2.php.

2162 {
2163 if (is_null($error)) {
2164 $error = $this->has_transaction_error ? $this->has_transaction_error : true;
2165 } elseif (!$error) {
2166 $error = true;
2167 }
2168 $this->has_transaction_error = $error;
2169 if (!$immediately) {
2170 return MDB2_OK;
2171 }
2172 return $this->rollback();
2173 }

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 1722 of file MDB2.php.

1723 {
1724 return $this->as_keyword;
1725 }

References $as_keyword.

◆ getConnection()

◆ getDatabase()

MDB2_Driver_Common::getDatabase ( )

Get the current database.

Returns
string name of the database

@access public

Definition at line 2283 of file MDB2.php.

2284 {
2285 return $this->database_name;
2286 }

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 1611 of file MDB2.php.

1612 {
1613 return $this->debug_output;
1614 }

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 3040 of file MDB2.php.

3041 {
3042 $result = $this->loadModule('Datatype', null, true);
3043 if (PEAR::isError($result)) {
3044 return $result;
3045 }
3046 return $this->datatype->getDeclaration($type, $name, $field);
3047 }

References $result, 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 2325 of file MDB2.php.

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

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

◆ 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 3125 of file MDB2.php.

3126 {
3127 return sprintf($this->options['idxname_format'],
3128 preg_replace('/[^a-z0-9_\$]/i', '_', $idx));
3129 }

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 2191 of file MDB2.php.

2192 {
2194 }

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 1561 of file MDB2.php.

1562 {
1563 if (array_key_exists($option, $this->options)) {
1564 return $this->options[$option];
1565 }
1566 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1567 "unknown option $option", __FUNCTION__);
1568 }

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 3107 of file MDB2.php.

3108 {
3109 return sprintf($this->options['seqname_format'],
3110 preg_replace('/[^a-z0-9_\$.]/i', '_', $sqn));
3111 }

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 2617 of file MDB2.php.

2618 {
2619 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2620 'method not implemented', __FUNCTION__);
2621 }

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 1482 of file MDB2.php.

1483 {
1484 return array_reverse($this->warnings);
1485 }

◆ 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 2018 of file MDB2.php.

2019 {
2020 if (!$ignore_nested && isset($this->nested_transaction_counter)) {
2022 }
2023 return $this->in_transaction;
2024 }

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 3164 of file MDB2.php.

3165 {
3166 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
3167 'method not implemented', __FUNCTION__);
3168 }

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 1845 of file MDB2.php.

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

3145 {
3146 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
3147 'method not implemented', __FUNCTION__);
3148 }

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 2860 of file MDB2.php.

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

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 2507 of file MDB2.php.

2508 {
2511 $this->offset = $this->limit = 0;
2512 $query = $this->_modifyQuery($query, false, $limit, $offset);
2513
2514 $connection = $this->getConnection();
2516 return $connection;
2517 }
2518
2519 $result =& $this->_doQuery($query, false, $connection, $this->database_name);
2520 if (PEAR::isError($result)) {
2521 return $result;
2522 }
2523
2524 $result =& $this->_wrapResult($result, $types, $result_class, $result_wrap_class, $limit, $offset);
2525 return $result;
2526 }
& _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:2546

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 3308 of file MDB2.php.

3310 {
3311 $result = $this->query($query, $types);
3313 return $result;
3314 }
3315
3316 $all = $result->fetchAll($fetchmode, $rekey, $force_array, $group);
3317 $result->free();
3318 return $all;
3319 }
& query($query, $types=null, $result_class=true, $result_wrap_class=false)
Send a query to the database and return any results.
Definition: MDB2.php:2507

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 3269 of file MDB2.php.

3270 {
3271 $result = $this->query($query, $type);
3273 return $result;
3274 }
3275
3276 $col = $result->fetchCol($colnum);
3277 $result->free();
3278 return $col;
3279 }

References $query, $result, 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 3208 of file MDB2.php.

3209 {
3210 $result = $this->query($query, $type);
3212 return $result;
3213 }
3214
3215 $one = $result->fetchOne($colnum);
3216 $result->free();
3217 return $one;
3218 }

References $query, $result, 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 3239 of file MDB2.php.

3240 {
3241 $result = $this->query($query, $types);
3243 return $result;
3244 }
3245
3246 $row = $result->fetchRow($fetchmode);
3247 $result->free();
3248 return $row;
3249 }

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 3014 of file MDB2.php.

3015 {
3016 $result = $this->loadModule('Datatype', null, true);
3017 if (PEAR::isError($result)) {
3018 return $result;
3019 }
3020
3021 return $this->datatype->quote($value, $type, $quote, $escape_wildcards);
3022 }

References $result, 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 1705 of file MDB2.php.

1706 {
1707 if ($check_option && !$this->options['quote_identifier']) {
1708 return $str;
1709 }
1710 $str = str_replace($this->identifier_quoting['end'], $this->identifier_quoting['escape'] . $this->identifier_quoting['end'], $str);
1711 return $this->identifier_quoting['start'] . $str . $this->identifier_quoting['end'];
1712 }

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 (   $code = null,
  $mode = null,
  $options = null,
  $userinfo = null,
  $method = null 
)

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

Definition at line 1412 of file MDB2.php.

1413 {
1414 $userinfo = "[Error message: $userinfo]\n";
1415 // The error is yet a MDB2 error object
1416 if (PEAR::isError($code)) {
1417 // because we use the static PEAR::raiseError, our global
1418 // handler should be used if it is set
1419 if (is_null($mode) && !empty($this->_default_error_mode)) {
1422 }
1423 if (is_null($userinfo)) {
1424 $userinfo = $code->getUserinfo();
1425 }
1426 $code = $code->getCode();
1427 } elseif ($code == MDB2_ERROR_NOT_FOUND) {
1428 // extension not loaded: don't call $this->errorInfo() or the script
1429 // will die
1430 } elseif (isset($this->connection)) {
1431 if (!empty($this->last_query)) {
1432 $userinfo.= "[Last executed query: {$this->last_query}]\n";
1433 }
1434 $native_errno = $native_msg = null;
1435 list($code, $native_errno, $native_msg) = $this->errorInfo($code);
1436 if (!is_null($native_errno) && $native_errno !== '') {
1437 $userinfo.= "[Native code: $native_errno]\n";
1438 }
1439 if (!is_null($native_msg) && $native_msg !== '') {
1440 $userinfo.= "[Native message: ". strip_tags($native_msg) ."]\n";
1441 }
1442 if (!is_null($method)) {
1443 $userinfo = $method.': '.$userinfo;
1444 }
1445 }
1446
1447 $err =& PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
1448 if ($err->getMode() !== PEAR_ERROR_RETURN
1449 && isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
1450 $this->has_transaction_error =& $err;
1451 }
1452 return $err;
1453 }
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 2765 of file MDB2.php.

2766 {
2767 if (!$this->supports('replace')) {
2768 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2769 'replace query is not supported', __FUNCTION__);
2770 }
2771 $count = count($fields);
2772 $condition = $values = array();
2773 for ($colnum = 0, reset($fields); $colnum < $count; next($fields), $colnum++) {
2774 $name = key($fields);
2775 if (isset($fields[$name]['null']) && $fields[$name]['null']) {
2776 $value = 'NULL';
2777 } else {
2778 $type = isset($fields[$name]['type']) ? $fields[$name]['type'] : null;
2779 $value = $this->quote($fields[$name]['value'], $type);
2780 }
2781 $values[$name] = $value;
2782 if (isset($fields[$name]['key']) && $fields[$name]['key']) {
2783 if ($value === 'NULL') {
2784 return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null,
2785 'key value '.$name.' may not be NULL', __FUNCTION__);
2786 }
2787 $condition[] = $name . '=' . $value;
2788 }
2789 }
2790 if (empty($condition)) {
2791 return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null,
2792 'not specified which fields are keys', __FUNCTION__);
2793 }
2794
2795 $result = null;
2798 return $result;
2799 }
2800
2801 $connection = $this->getConnection();
2803 return $connection;
2804 }
2805
2806 $condition = ' WHERE '.implode(' AND ', $condition);
2807 $query = "DELETE FROM $table$condition";
2808 $result =& $this->_doQuery($query, true, $connection);
2809 if (!PEAR::isError($result)) {
2810 $affected_rows = $this->_affectedRows($connection, $result);
2811 $insert = implode(', ', array_keys($values));
2812 $values = implode(', ', $values);
2813 $query = "INSERT INTO $table ($insert) VALUES ($values)";
2814 $result =& $this->_doQuery($query, true, $connection);
2815 if (!PEAR::isError($result)) {
2816 $affected_rows += $this->_affectedRows($connection, $result);;
2817 }
2818 }
2819
2820 if (!$in_transaction) {
2821 if (PEAR::isError($result)) {
2822 $this->rollback();
2823 } else {
2824 $result = $this->commit();
2825 }
2826 }
2827
2828 if (PEAR::isError($result)) {
2829 return $result;
2830 }
2831
2832 return $affected_rows;
2833 }
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:3014
$insert

References $connection, $in_transaction, $insert, $query, $result, _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 1465 of file MDB2.php.

1466 {
1467 $this->warnings = array();
1468 }

◆ 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 1997 of file MDB2.php.

1998 {
1999 $this->debug('Rolling back transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
2000 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2001 'rolling back transactions is not supported', __FUNCTION__);
2002 }

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 2221 of file MDB2.php.

2222 {
2223 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2224 'method not implemented', __FUNCTION__);
2225 }

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 2265 of file MDB2.php.

2266 {
2267 $previous_database_name = (isset($this->database_name)) ? $this->database_name : '';
2268 $this->database_name = $name;
2269 $this->disconnect(false);
2270 return $previous_database_name;
2271 }

References 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 2300 of file MDB2.php.

2301 {
2302 $dsn_default = $GLOBALS['_MDB2_dsninfo_default'];
2304 if (array_key_exists('database', $dsn)) {
2305 $this->database_name = $dsn['database'];
2306 unset($dsn['database']);
2307 }
2308 $this->dsn = array_merge($dsn_default, $dsn);
2309 return $this->disconnect(false);
2310 }
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 1509 of file MDB2.php.

1510 {
1511 switch ($fetchmode) {
1513 $this->options['fetch_class'] = $object_class;
1516 $this->fetchmode = $fetchmode;
1517 break;
1518 default:
1519 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1520 'invalid fetchmode mode', __FUNCTION__);
1521 }
1522
1523 return MDB2_OK;
1524 }
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 2636 of file MDB2.php.

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

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 1539 of file MDB2.php.

1540 {
1541 if (array_key_exists($option, $this->options)) {
1542 $this->options[$option] = $value;
1543 return MDB2_OK;
1544 }
1545 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
1546 "unknown option $option", __FUNCTION__);
1547 }

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 2045 of file MDB2.php.

2046 {
2047 $this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true));
2048 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2049 'isolation level setting is not supported', __FUNCTION__);
2050 }

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 2365 of file MDB2.php.

2366 {
2369 $this->offset = $this->limit = 0;
2370 $query = $this->_modifyQuery($query, $is_manip, $limit, $offset);
2371
2372 $connection = $this->getConnection();
2374 return $connection;
2375 }
2376
2377 $result =& $this->_doQuery($query, $is_manip, $connection, false);
2378 if (PEAR::isError($result)) {
2379 return $result;
2380 }
2381
2382 if ($is_manip) {
2383 $affected_rows = $this->_affectedRows($connection, $result);
2384 return $affected_rows;
2385 }
2386 $result =& $this->_wrapResult($result, $types, true, false, $limit, $offset);
2387 return $result;
2388 }

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 2674 of file MDB2.php.

2675 {
2676 if ($this->supports('sub_selects') === true) {
2677 return $query;
2678 }
2679
2680 if (!$this->supports('sub_selects')) {
2681 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
2682 'method not implemented', __FUNCTION__);
2683 }
2684
2685 $col = $this->queryCol($query, $type);
2686 if (PEAR::isError($col)) {
2687 return $col;
2688 }
2689 if (!is_array($col) || count($col) == 0) {
2690 return 'NULL';
2691 }
2692 if ($type) {
2693 $this->loadModule('Datatype', null, true);
2694 return $this->datatype->implodeArray($col, $type);
2695 }
2696 return implode(', ', $col);
2697 }
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:3269

References $query, 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 3086 of file MDB2.php.

3087 {
3088 if (array_key_exists($feature, $this->supported)) {
3089 return $this->supported[$feature];
3090 }
3091 return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
3092 "unknown support feature $feature", __FUNCTION__);
3093 }

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: