ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
MDB2_Driver_mysqli Class Reference
+ Inheritance diagram for MDB2_Driver_mysqli:
+ Collaboration diagram for MDB2_Driver_mysqli:

Public Member Functions

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

Data Fields

 $string_quoting = array('start' => "'", 'end' => "'", 'escape' => '\\', 'escape_pattern' => '\\')
 $identifier_quoting = array('start' => '`', 'end' => '`', 'escape' => '`')
 $sql_comments
 $start_transaction = false
 $varchar_max_length = 255
- Data Fields inherited from MDB2_Driver_Common
 $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()

Detailed Description

Definition at line 56 of file mysqli.php.

Constructor & Destructor Documentation

MDB2_Driver_mysqli::__construct ( )

Constructor.

Reimplemented from MDB2_Driver_Common.

Definition at line 78 of file mysqli.php.

{
$this->phptype = 'mysqli';
$this->dbsyntax = 'mysql';
$this->supported['sequences'] = 'emulated';
$this->supported['indexes'] = true;
$this->supported['affected_rows'] = true;
$this->supported['transactions'] = false;
$this->supported['savepoints'] = false;
$this->supported['summary_functions'] = true;
$this->supported['order_by_text'] = true;
$this->supported['current_id'] = 'emulated';
$this->supported['limit_queries'] = true;
$this->supported['LOBs'] = true;
$this->supported['replace'] = true;
$this->supported['sub_selects'] = 'emulated';
$this->supported['auto_increment'] = true;
$this->supported['primary_key'] = true;
$this->supported['result_introspection'] = true;
$this->supported['prepared_statements'] = 'emulated';
$this->supported['identifier_quoting'] = true;
$this->supported['pattern_escaping'] = true;
$this->supported['new_link'] = true;
$this->options['default_table_type'] = '';
$this->options['multi_query'] = false;
}

Member Function Documentation

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

Returns the number of rows affected.

Parameters
resource$result
resource$connection
Returns
mixed MDB2 Error Object or the number of rows affected private

Reimplemented from MDB2_Driver_Common.

Definition at line 647 of file mysqli.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\getConnection(), and PEAR\isError().

Referenced by replace().

{
if (is_null($connection)) {
return $connection;
}
}
return @mysqli_affected_rows($connection);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Execute a query.

Parameters
string$queryquery
boolean$is_manipif the query is a manipulation query
resource$connection
string$database_name
Returns
result or error object protected

Reimplemented from MDB2_Driver_Common.

Definition at line 569 of file mysqli.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\$database_name, $query, $result, MDB2_Driver_Common\debug(), MDB2_Driver_Common\getConnection(), PEAR\isError(), and MDB2_Driver_Common\raiseError().

Referenced by beginTransaction(), commit(), nextID(), prepare(), replace(), rollback(), setCharset(), and setTransactionIsolation().

{
$this->last_query = $query;
$result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
if ($result) {
return $result;
}
}
if ($this->options['disable_query']) {
$result = $is_manip ? 0 : null;
return $result;
}
if (is_null($connection)) {
return $connection;
}
}
if (is_null($database_name)) {
}
if ($database_name != $this->connected_database_name) {
if (!@mysqli_select_db($connection, $database_name)) {
$err = $this->raiseError(null, null, null,
'Could not select the database: '.$database_name, __FUNCTION__);
return $err;
}
$this->connected_database_name = $database_name;
}
}
if ($this->options['multi_query']) {
$result = mysqli_multi_query($connection, $query);
} else {
$resultmode = $this->options['result_buffering'] ? MYSQLI_USE_RESULT : MYSQLI_USE_RESULT;
$result = mysqli_query($connection, $query);
}
if (!$result) {
$err =& $this->raiseError(null, null, null,
'Could not execute statement', __FUNCTION__);
return $err;
}
if ($this->options['multi_query']) {
if ($this->options['result_buffering']) {
if (!($result = @mysqli_store_result($connection))) {
$err =& $this->raiseError(null, null, null,
'Could not get the first result from a multi query', __FUNCTION__);
return $err;
}
} elseif (!($result = @mysqli_use_result($connection))) {
$err =& $this->raiseError(null, null, null,
'Could not get the first result from a multi query', __FUNCTION__);
return $err;
}
}
$this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'post', 'result' => $result));
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_mysqli::_getServerCapabilities ( )

Fetch some information about the server capabilities (transactions, subselects, prepared statements, etc).

private

Definition at line 767 of file mysqli.php.

References getServerVersion().

Referenced by beginTransaction(), and connect().

{
static $already_checked = false;
if (!$already_checked) {
$already_checked = true;
//set defaults
$this->supported['sub_selects'] = 'emulated';
$this->supported['prepared_statements'] = 'emulated';
$this->start_transaction = false;
$this->varchar_max_length = 255;
$server_info = $this->getServerVersion();
if (is_array($server_info)) {
if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.0', '<')) {
$this->supported['sub_selects'] = true;
$this->supported['prepared_statements'] = true;
}
if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.14', '<')
|| !version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.1', '<')
) {
$this->supported['savepoints'] = true;
}
if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.11', '<')) {
$this->start_transaction = true;
}
if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '5.0.3', '<')) {
$this->varchar_max_length = 65532;
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Changes a query string for various DBMS specific reasons.

Parameters
string$queryquery to modify
boolean$is_manipif it is a DML query
integer$limitlimit the number of rows
integer$offsetstart reading from given offset
Returns
string modified query protected

Reimplemented from MDB2_Driver_Common.

Definition at line 671 of file mysqli.php.

References MDB2_Driver_Common\$limit, $query, and MDB2_PORTABILITY_DELETE_COUNT.

Referenced by prepare().

{
if ($this->options['portability'] & MDB2_PORTABILITY_DELETE_COUNT) {
// "DELETE FROM table" gives 0 affected rows in MySQL.
// This little hack lets you know how many rows were deleted.
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) {
$query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
'DELETE FROM \1 WHERE 1=1', $query);
}
}
if ($limit > 0
&& !preg_match('/LIMIT\s*\d(?:\s*(?:,|OFFSET)\s*\d+)?(?:[^\)]*)?$/i', $query)
) {
$query = rtrim($query);
if (substr($query, -1) == ';') {
$query = substr($query, 0, -1);
}
// LIMIT doesn't always come last in the query
// @see http://dev.mysql.com/doc/refman/5.0/en/select.html
$after = '';
if (preg_match('/(\s+INTO\s+(?:OUT|DUMP)FILE\s.*)$/ims', $query, $matches)) {
$after = $matches[0];
$query = preg_replace('/(\s+INTO\s+(?:OUT|DUMP)FILE\s.*)$/ims', '', $query);
} elseif (preg_match('/(\s+FOR\s+UPDATE\s*)$/i', $query, $matches)) {
$after = $matches[0];
$query = preg_replace('/(\s+FOR\s+UPDATE\s*)$/im', '', $query);
} elseif (preg_match('/(\s+LOCK\s+IN\s+SHARE\s+MODE\s*)$/im', $query, $matches)) {
$after = $matches[0];
$query = preg_replace('/(\s+LOCK\s+IN\s+SHARE\s+MODE\s*)$/im', '', $query);
}
if ($is_manip) {
return $query . " LIMIT $limit";
} else {
return $query . " LIMIT $offset, $limit";
}
}
return $query;
}

+ Here is the caller graph for this function:

MDB2_Driver_mysqli::_skipUserDefinedVariable (   $query,
  $position 
)

Utility method, used by prepare() to avoid misinterpreting MySQL user defined variables (SELECT :=5) for placeholders.

Check if the placeholder is a false positive, i.e. if it is an user defined variable instead. If so, skip it and advance the position, otherwise return the current position, which is valid

Parameters
string$query
integer$positioncurrent string cursor position
Returns
integer $new_position protected

Definition at line 818 of file mysqli.php.

References $query.

Referenced by prepare().

{
$found = strpos(strrev(substr($query, 0, $position)), '@');
if ($found === false) {
return $position;
}
$pos = strlen($query) - strlen(substr($query, $position)) - $found - 1;
$substring = substr($query, $pos, $position - $pos + 2);
if (preg_match('/^@\w+:=$/', $substring)) {
return $position + 1; //found an user defined variable: skip it
}
return $position;
}

+ Here is the caller graph for this function:

MDB2_Driver_mysqli::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

public

Reimplemented from MDB2_Driver_Common.

Definition at line 215 of file mysqli.php.

References $query, $result, _doQuery(), _getServerCapabilities(), MDB2_Driver_Common\debug(), PEAR\isError(), MDB2_ERROR_INVALID, MDB2_ERROR_UNSUPPORTED, MDB2_OK, MDB2_Driver_Common\raiseError(), and MDB2_Driver_Common\supports().

{
$this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
if (!is_null($savepoint)) {
if (!$this->supports('savepoints')) {
return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'savepoints are not supported', __FUNCTION__);
}
if (!$this->in_transaction) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null,
'savepoint cannot be released when changes are auto committed', __FUNCTION__);
}
$query = 'SAVEPOINT '.$savepoint;
return $this->_doQuery($query, true);
} elseif ($this->in_transaction) {
return MDB2_OK; //nothing to do
}
$query = $this->start_transaction ? 'START TRANSACTION' : 'SET AUTOCOMMIT = 1';
$result =& $this->_doQuery($query, true);
return $result;
}
$this->in_transaction = true;
return MDB2_OK;
}

+ Here is the call graph for this function:

MDB2_Driver_mysqli::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

public

Reimplemented from MDB2_Driver_Common.

Definition at line 256 of file mysqli.php.

References $query, $result, _doQuery(), MDB2_Driver_Common\debug(), getServerVersion(), PEAR\isError(), MDB2_ERROR_INVALID, MDB2_ERROR_UNSUPPORTED, MDB2_OK, MDB2_Driver_Common\raiseError(), and MDB2_Driver_Common\supports().

{
$this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
if (!$this->in_transaction) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null,
'commit/release savepoint cannot be done changes are auto committed', __FUNCTION__);
}
if (!is_null($savepoint)) {
if (!$this->supports('savepoints')) {
return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'savepoints are not supported', __FUNCTION__);
}
$server_info = $this->getServerVersion();
if (version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '5.0.3', '<')) {
return MDB2_OK;
}
$query = 'RELEASE SAVEPOINT '.$savepoint;
return $this->_doQuery($query, true);
}
if (!$this->supports('transactions')) {
return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'transactions are not supported', __FUNCTION__);
}
$result =& $this->_doQuery('COMMIT', true);
return $result;
}
if (!$this->start_transaction) {
$query = 'SET AUTOCOMMIT = 0';
$result =& $this->_doQuery($query, true);
return $result;
}
}
$this->in_transaction = false;
return MDB2_OK;
}

+ Here is the call graph for this function:

MDB2_Driver_mysqli::connect ( )

Connect to the database.

Returns
true on success, MDB2 Error Object on failure

Reimplemented from MDB2_Driver_Common.

Definition at line 388 of file mysqli.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\$database_name, MDB2_Driver_Common\$dsn, MDB2_Driver_Common\$phptype, $result, _getServerCapabilities(), PEAR\isError(), PEAR\loadExtension(), MDB2_ERROR_CONNECT_FAILED, MDB2_ERROR_NOT_FOUND, MDB2_OK, MDB2_Driver_Common\raiseError(), and setCharset().

{
if (is_object($this->connection)) {
if (count(array_diff($this->connected_dsn, $this->dsn)) == 0) {
return MDB2_OK;
}
$this->connection = 0;
}
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'extension '.$this->phptype.' is not compiled into PHP', __FUNCTION__);
}
if ($this->options['ssl']) {
$init = @mysqli_init();
@mysqli_ssl_set(
$init,
empty($this->dsn['key']) ? null : $this->dsn['key'],
empty($this->dsn['cert']) ? null : $this->dsn['cert'],
empty($this->dsn['ca']) ? null : $this->dsn['ca'],
empty($this->dsn['capath']) ? null : $this->dsn['capath'],
empty($this->dsn['cipher']) ? null : $this->dsn['cipher']
);
if ($connection = @mysqli_real_connect(
$init,
$this->dsn['hostspec'],
$this->dsn['username'],
$this->dsn['password'],
$this->database_name,
$this->dsn['port'],
$this->dsn['socket']))
{
$connection = $init;
}
} else {
// hhvm-patch: begin
// HHVM-Fix: "Socket" must be a string!
if(!is_string($this->dsn['socket'])) {
$this->dsn['socket'] = "";
}
if(!is_string($this->dsn['port'])) {
$this->dsn['port'] = 0;
}
// HHVM-Fix: use "new mysqli" instead of "@mysqli_connect"
$connection = @new mysqli(
// hhvm-patch: end
$this->dsn['hostspec'],
$this->dsn['username'],
$this->dsn['password'],
$this->database_name,
$this->dsn['port'],
$this->dsn['socket']
);
// hhvm-patch: begin
if($connection->connect_error)
{
// Changed data type to boolean on connection errors to adapt mysqli_connect()
$connection = false;
}
// hhvm-patch: end
}
if (!$connection) {
if (($err = @mysqli_connect_error()) != '') {
return $this->raiseError(null,
null, null, $err, __FUNCTION__);
} else {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null,
'unable to establish a connection', __FUNCTION__);
}
}
if (!empty($this->dsn['charset'])) {
$result = $this->setCharset($this->dsn['charset'], $connection);
return $result;
}
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $this->database_name;
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
$this->supported['transactions'] = $this->options['use_transactions'];
if ($this->options['default_table_type']) {
switch (strtoupper($this->options['default_table_type'])) {
case 'BLACKHOLE':
case 'MEMORY':
case 'ARCHIVE':
case 'CSV':
case 'HEAP':
case 'ISAM':
case 'MERGE':
case 'MRG_ISAM':
case 'ISAM':
case 'MRG_MYISAM':
case 'MYISAM':
$this->supported['transactions'] = false;
$this->warnings[] = $this->options['default_table_type'] .
' is not a supported default table type';
break;
}
}
return MDB2_OK;
}

+ Here is the call graph for this function:

MDB2_Driver_mysqli::currID (   $seq_name)

Returns the current id of a sequence.

Parameters
string$seq_namename of the sequence
Returns
mixed MDB2 Error Object or id public

Reimplemented from MDB2_Driver_Common.

Definition at line 1148 of file mysqli.php.

References $query, MDB2_Driver_Common\getSequenceName(), MDB2_Driver_Common\queryOne(), and MDB2_Driver_Common\quoteIdentifier().

{
$sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true);
$seqcol_name = $this->quoteIdentifier($this->options['seqcol_name'], true);
$query = "SELECT MAX($seqcol_name) FROM $sequence_name";
return $this->queryOne($query, 'integer');
}

+ Here is the call graph for this function:

MDB2_Driver_mysqli::disconnect (   $force = true)

Log out and disconnect from the database.

Parameters
boolean$forceif 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 public

Reimplemented from MDB2_Driver_Common.

Definition at line 534 of file mysqli.php.

References MDB2_Driver_Common\$connected_database_name, MDB2_Driver_Common\$connected_dsn, MDB2_Driver_Common\$database_name, MDB2_Driver_Common\$dsn, MDB2_Driver_Common\$opened_persistent, and rollback().

{
if (is_object($this->connection)) {
if ($this->in_transaction) {
$persistent = $this->options['persistent'];
$this->dsn = $this->connected_dsn;
$this->database_name = $this->connected_database_name;
$this->options['persistent'] = $this->opened_persistent;
$this->rollback();
$this->dsn = $dsn;
$this->database_name = $database_name;
$this->options['persistent'] = $persistent;
}
if ($force) {
@mysqli_close($this->connection);
}
}
return parent::disconnect($force);
}

+ Here is the call graph for this function:

MDB2_Driver_mysqli::errorInfo (   $error = null)

This method is used to collect information about an error.

Parameters
integer$error
Returns
array public

Reimplemented from MDB2_Driver_Common.

Definition at line 119 of file mysqli.php.

References MDB2_ERROR_ACCESS_VIOLATION, MDB2_ERROR_ALREADY_EXISTS, MDB2_ERROR_CANNOT_CREATE, MDB2_ERROR_CANNOT_DROP, MDB2_ERROR_CONSTRAINT, MDB2_ERROR_CONSTRAINT_NOT_NULL, MDB2_ERROR_DIVZERO, MDB2_ERROR_NODBSELECTED, MDB2_ERROR_NOSUCHDB, MDB2_ERROR_NOSUCHFIELD, MDB2_ERROR_NOSUCHTABLE, MDB2_ERROR_NOT_FOUND, MDB2_ERROR_NOT_LOCKED, MDB2_ERROR_SYNTAX, MDB2_ERROR_VALUE_COUNT_ON_ROW, and MDB2_PORTABILITY_ERRORS.

{
if ($this->connection) {
$native_code = @mysqli_errno($this->connection);
$native_msg = @mysqli_error($this->connection);
} else {
$native_code = @mysqli_connect_errno();
$native_msg = @mysqli_connect_error();
}
if (is_null($error)) {
static $ecode_map;
if (empty($ecode_map)) {
$ecode_map = array(
);
}
if ($this->options['portability'] & MDB2_PORTABILITY_ERRORS) {
$ecode_map[1022] = MDB2_ERROR_CONSTRAINT;
$ecode_map[1048] = MDB2_ERROR_CONSTRAINT_NOT_NULL;
$ecode_map[1062] = MDB2_ERROR_CONSTRAINT;
} else {
// Doing this in case mode changes during runtime.
$ecode_map[1022] = MDB2_ERROR_ALREADY_EXISTS;
$ecode_map[1048] = MDB2_ERROR_CONSTRAINT;
$ecode_map[1062] = MDB2_ERROR_ALREADY_EXISTS;
}
if (isset($ecode_map[$native_code])) {
$error = $ecode_map[$native_code];
}
}
return array($error, $native_code, $native_msg);
}
MDB2_Driver_mysqli::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

public

Reimplemented from MDB2_Driver_Common.

Definition at line 191 of file mysqli.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\escapePattern(), MDB2_Driver_Common\getConnection(), and PEAR\isError().

{
if ($escape_wildcards) {
$text = $this->escapePattern($text);
}
return $connection;
}
$text = @mysqli_real_escape_string($connection, $text);
return $text;
}

+ Here is the call graph for this function:

MDB2_Driver_mysqli::getServerVersion (   $native = false)

return version information about the server

Parameters
bool$nativedetermines if the raw version string should be returned
Returns
mixed array/string with version information or MDB2 error object public

Reimplemented from MDB2_Driver_Common.

Definition at line 722 of file mysqli.php.

References MDB2_Driver_Common\$connected_server_info, MDB2_Driver_Common\$connection, MDB2_Driver_Common\getConnection(), PEAR\isError(), and MDB2_Driver_Common\raiseError().

Referenced by _getServerCapabilities(), and commit().

{
return $connection;
}
if ($this->connected_server_info) {
} else {
$server_info = @mysqli_get_server_info($connection);
}
if (!$server_info) {
return $this->raiseError(null, null, null,
'Could not get server information', __FUNCTION__);
}
// cache server_info
$this->connected_server_info = $server_info;
if (!$native) {
$tmp = explode('.', $server_info, 3);
if (isset($tmp[2]) && strpos($tmp[2], '-')) {
$tmp2 = explode('-', @$tmp[2], 2);
} else {
$tmp2[0] = isset($tmp[2]) ? $tmp[2] : null;
$tmp2[1] = null;
}
$server_info = array(
'major' => isset($tmp[0]) ? $tmp[0] : null,
'minor' => isset($tmp[1]) ? $tmp[1] : null,
'patch' => $tmp2[0],
'extra' => $tmp2[1],
'native' => $server_info,
);
}
return $server_info;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_mysqli::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
string$tablename of the table into which a new row was inserted
string$fieldname of the field into which a new row was inserted
Returns
mixed MDB2 Error Object or id public

Reimplemented from MDB2_Driver_Common.

Definition at line 1132 of file mysqli.php.

References MDB2_Driver_Common\queryOne().

Referenced by nextID().

{
// not using mysql_insert_id() due to http://pear.php.net/bugs/bug.php?id=8051
return $this->queryOne('SELECT LAST_INSERT_ID()');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Returns the next free id of a sequence.

Parameters
string$seq_namename of the sequence
boolean$ondemandwhen true the sequence is automatic created, if it not exists
Returns
mixed MDB2 Error Object or id public

Reimplemented from MDB2_Driver_Common.

Definition at line 1088 of file mysqli.php.

References $query, $result, _doQuery(), PEAR\expectError(), MDB2_Driver_Common\getSequenceName(), PEAR\isError(), lastInsertID(), MDB2_Driver_Common\loadModule(), MDB2_ERROR_NOSUCHTABLE, PEAR\popExpect(), MDB2_Driver_Common\quoteIdentifier(), and MDB2_Driver_Common\raiseError().

{
$sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true);
$seqcol_name = $this->quoteIdentifier($this->options['seqcol_name'], true);
$query = "INSERT INTO $sequence_name ($seqcol_name) VALUES (NULL)";
$result =& $this->_doQuery($query, true);
$this->popExpect();
if ($ondemand && $result->getCode() == MDB2_ERROR_NOSUCHTABLE) {
$this->loadModule('Manager', null, true);
$result = $this->manager->createSequence($seq_name);
return $this->raiseError($result, null, null,
'on demand sequence '.$seq_name.' could not be created', __FUNCTION__);
} else {
return $this->nextID($seq_name, false);
}
}
return $result;
}
$value = $this->lastInsertID();
if (is_numeric($value)) {
$query = "DELETE FROM $sequence_name WHERE $seqcol_name < $value";
$result =& $this->_doQuery($query, true);
$this->warnings[] = 'nextID: could not delete previous sequence table values from '.$seq_name;
}
}
return $value;
}

+ Here is the call graph for this function:

& MDB2_Driver_mysqli::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
string$querythe query to prepare
mixed$typesarray that contains the types of the placeholders
mixed$result_typesarray 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
mixed$lobskey (field) value (parameter) pair for all lob placeholders
Returns
mixed resource handle for the prepared query on success, a MDB2 error on failure public
See Also
bindParam, execute

Reimplemented from MDB2_Driver_Common.

Definition at line 855 of file mysqli.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\$limit, MDB2_Driver_Common\$offset, $query, $result, _doQuery(), _modifyQuery(), MDB2_Driver_Common\_skipDelimitedStrings(), _skipUserDefinedVariable(), MDB2_Driver_Common\debug(), MDB2_Driver_Common\getConnection(), PEAR\isError(), MDB2_ERROR_SYNTAX, MDB2_PREPARE_MANIP, and MDB2_Driver_Common\raiseError().

{
if ($this->options['emulate_prepared']
|| $this->supported['prepared_statements'] !== true
) {
$obj =& parent::prepare($query, $types, $result_types, $lobs);
return $obj;
}
$is_manip = ($result_types === MDB2_PREPARE_MANIP);
$this->offset = $this->limit = 0;
$query = $this->_modifyQuery($query, $is_manip, $limit, $offset);
$result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre'));
if ($result) {
return $result;
}
}
$placeholder_type_guess = $placeholder_type = null;
$question = '?';
$colon = ':';
$positions = array();
$position = 0;
while ($position < strlen($query)) {
$q_position = strpos($query, $question, $position);
$c_position = strpos($query, $colon, $position);
if ($q_position && $c_position) {
$p_position = min($q_position, $c_position);
} elseif ($q_position) {
$p_position = $q_position;
} elseif ($c_position) {
$p_position = $c_position;
} else {
break;
}
if (is_null($placeholder_type)) {
$placeholder_type_guess = $query[$p_position];
}
$new_pos = $this->_skipDelimitedStrings($query, $position, $p_position);
if (PEAR::isError($new_pos)) {
return $new_pos;
}
if ($new_pos != $position) {
$position = $new_pos;
continue; //evaluate again starting from the new position
}
if ($query[$position] == $placeholder_type_guess) {
if (is_null($placeholder_type)) {
$placeholder_type = $query[$p_position];
$question = $colon = $placeholder_type;
}
if ($placeholder_type == ':') {
//make sure this is not part of an user defined variable
$new_pos = $this->_skipUserDefinedVariable($query, $position);
if ($new_pos != $position) {
$position = $new_pos;
continue; //evaluate again starting from the new position
}
$parameter = preg_replace('/^.{'.($position+1).'}([a-z0-9_]+).*$/si', '\\1', $query);
if ($parameter === '') {
$err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
'named parameter with an empty name', __FUNCTION__);
return $err;
}
$positions[$p_position] = $parameter;
$query = substr_replace($query, '?', $position, strlen($parameter)+1);
} else {
$positions[$p_position] = count($positions);
}
$position = $p_position + 1;
} else {
$position = $p_position;
}
}
return $connection;
}
if (!$is_manip) {
$statement_name = sprintf($this->options['statement_format'], $this->phptype, md5(time() + rand()));
$query = "PREPARE $statement_name FROM ".$this->quote($query, 'text');
$statement =& $this->_doQuery($query, true, $connection);
if (PEAR::isError($statement)) {
return $statement;
}
$statement = $statement_name;
} else {
$statement = @mysqli_prepare($connection, $query);
if (!$statement) {
$err =& $this->raiseError(null, null, null,
'Unable to create prepared statement handle', __FUNCTION__);
return $err;
}
}
$class_name = 'MDB2_Statement_'.$this->phptype;
$obj =& new $class_name($this, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset);
$this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'post', 'result' => $obj));
return $obj;
}

+ Here is the call graph for this function:

MDB2_Driver_mysqli::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 implements it natively, this type of query is emulated through this method for other DBMS using standard types of queries inside a transaction to assure the atomicity of the operation.

public

Parameters
string$tablename of the table on which the REPLACE query will be executed.
array$fieldsassociative 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 Metabase are supported except for clob and blob.

Default: no type conversion

null Boolean 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 Boolean 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

Reimplemented from MDB2_Driver_Common.

Definition at line 1029 of file mysqli.php.

References MDB2_Driver_Common\$connection, $query, $result, _affectedRows(), _doQuery(), MDB2_Driver_Common\getConnection(), PEAR\isError(), MDB2_ERROR_CANNOT_REPLACE, MDB2_Driver_Common\quote(), and MDB2_Driver_Common\raiseError().

{
$count = count($fields);
$query = $values = '';
$keys = $colnum = 0;
for (reset($fields); $colnum < $count; next($fields), $colnum++) {
$name = key($fields);
if ($colnum > 0) {
$query .= ',';
$values.= ',';
}
$query.= $name;
if (isset($fields[$name]['null']) && $fields[$name]['null']) {
$value = 'NULL';
} else {
$type = isset($fields[$name]['type']) ? $fields[$name]['type'] : null;
$value = $this->quote($fields[$name]['value'], $type);
}
$values.= $value;
if (isset($fields[$name]['key']) && $fields[$name]['key']) {
if ($value === 'NULL') {
return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null,
'key value '.$name.' may not be NULL', __FUNCTION__);
}
$keys++;
}
}
if ($keys == 0) {
return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null,
'not specified which fields are keys', __FUNCTION__);
}
return $connection;
}
$query = "REPLACE INTO $table ($query) VALUES ($values)";
$result =& $this->_doQuery($query, true, $connection);
return $result;
}
}

+ Here is the call graph for this function:

MDB2_Driver_mysqli::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

public

Reimplemented from MDB2_Driver_Common.

Definition at line 310 of file mysqli.php.

References $query, $result, _doQuery(), MDB2_Driver_Common\debug(), PEAR\isError(), MDB2_ERROR_INVALID, MDB2_ERROR_UNSUPPORTED, MDB2_OK, MDB2_Driver_Common\raiseError(), and MDB2_Driver_Common\supports().

Referenced by disconnect().

{
$this->debug('Rolling back transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
if (!$this->in_transaction) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null,
'rollback cannot be done changes are auto committed', __FUNCTION__);
}
if (!is_null($savepoint)) {
if (!$this->supports('savepoints')) {
return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'savepoints are not supported', __FUNCTION__);
}
$query = 'ROLLBACK TO SAVEPOINT '.$savepoint;
return $this->_doQuery($query, true);
}
$query = 'ROLLBACK';
$result =& $this->_doQuery($query, true);
return $result;
}
if (!$this->start_transaction) {
$query = 'SET AUTOCOMMIT = 0';
$result =& $this->_doQuery($query, true);
return $result;
}
}
$this->in_transaction = false;
return MDB2_OK;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_mysqli::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 from MDB2_Driver_Common.

Definition at line 510 of file mysqli.php.

References MDB2_Driver_Common\$connection, $query, _doQuery(), MDB2_Driver_Common\getConnection(), and PEAR\isError().

Referenced by connect().

{
if (is_null($connection)) {
return $connection;
}
}
$query = "SET NAMES '".mysqli_real_escape_string($connection, $charset)."'";
return $this->_doQuery($query, true, $connection);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_mysqli::setTransactionIsolation (   $isolation)

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)
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Since
2.1.1

Definition at line 358 of file mysqli.php.

References $query, _doQuery(), MDB2_Driver_Common\debug(), MDB2_ERROR_UNSUPPORTED, MDB2_Driver_Common\raiseError(), and MDB2_Driver_Common\supports().

{
$this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true));
if (!$this->supports('transactions')) {
return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'transactions are not supported', __FUNCTION__);
}
switch ($isolation) {
case 'READ UNCOMMITTED':
case 'READ COMMITTED':
case 'REPEATABLE READ':
case 'SERIALIZABLE':
break;
default:
return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'isolation level is not supported: '.$isolation, __FUNCTION__);
}
$query = "SET SESSION TRANSACTION ISOLATION LEVEL $isolation";
return $this->_doQuery($query, true);
}

+ Here is the call graph for this function:

Field Documentation

MDB2_Driver_mysqli::$identifier_quoting = array('start' => '`', 'end' => '`', 'escape' => '`')

Definition at line 61 of file mysqli.php.

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

Definition at line 63 of file mysqli.php.

MDB2_Driver_mysqli::$start_transaction = false

Definition at line 69 of file mysqli.php.

MDB2_Driver_mysqli::$string_quoting = array('start' => "'", 'end' => "'", 'escape' => '\\', 'escape_pattern' => '\\')

Definition at line 59 of file mysqli.php.

MDB2_Driver_mysqli::$varchar_max_length = 255

Definition at line 71 of file mysqli.php.


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