Class DB_mysqli

Description

Database independent query interface definition for PHP's mysqli extension.

This is for MySQL versions 4.1 and above. Requires PHP 5.

Note that persistent connections no longer exist.

  • since: Class functional since Release 1.6.3
  • author: Daniel Convissor <danielc@php.net>
  • version: $Id: mysqli.php,v 1.31 2004/07/12 17:51:24 danielc Exp $

Located in /maintenance/libraries/pear/DB/mysqli.php (line 41)

PEAR
   |
   --DB_common
      |
      --DB_mysqli
Variable Summary
Method Summary
 DB_mysqli DB_mysqli ()
 integer affectedRows ()
 void autoCommit ([mixed $onoff = false])
 void commit ()
 mixed connect (mixed $dsninfo, [boolean $persistent = false], string $dsn)
 int createSequence (string $seq_name)
 boolean disconnect ()
 int dropSequence (string $seq_name)
 int errorNative ()
 string escapeSimple (string $str)
 mixed fetchInto (resource $result, array &$arr, int $fetchmode, [int $rownum = null])
 bool freeResult (resource $result)
 string getSpecialQuery (string $type)
 void modifyLimitQuery (mixed $query, mixed $from, mixed $count, [mixed $params = array()])
 void modifyQuery (mixed $query)
 object DB mysqlRaiseError ([integer $errno = null])
 int nextId (string $seq_name, [boolean $ondemand = true])
 false nextResult (resource $result)
 int numCols ($result $result)
 int numRows (resource $result)
 string quoteIdentifier (string $str)
 void rollback ()
 mixed simpleQuery (string $query)
 array tableInfo (object|string $result, [int $mode = null])
 mixed _BCsequence (string $seqname)
Variables
mixed $autocommit = true (line 51)
mixed $connection (line 45)
mixed $dbsyntax (line 46)
mixed $fetchmode = DB_FETCHMODE_ORDERED (line 52)

Redefinition of:
DB_common::$fetchmode
array $mysqli_flags = array(
MYSQLI_NOT_NULL_FLAG => 'not_null',
MYSQLI_PRI_KEY_FLAG => 'primary_key',
MYSQLI_UNIQUE_KEY_FLAG => 'unique_key',
MYSQLI_MULTIPLE_KEY_FLAG => 'multiple_key',
MYSQLI_BLOB_FLAG => 'blob',
MYSQLI_UNSIGNED_FLAG => 'unsigned',
MYSQLI_ZEROFILL_FLAG => 'zerofill',
MYSQLI_AUTO_INCREMENT_FLAG => 'auto_increment',
MYSQLI_TIMESTAMP_FLAG => 'timestamp',
MYSQLI_SET_FLAG => 'set',
// MYSQLI_NUM_FLAG => 'numeric', // unnecessary
// MYSQLI_PART_KEY_FLAG => 'multiple_key', // duplicatvie
MYSQLI_GROUP_FLAG => 'group_by'
)
(line 61)

Array for converting MYSQLI_*_FLAG constants to text values

  • since: Property available since Release 1.6.5
  • access: public
array $mysqli_types = array(
MYSQLI_TYPE_DECIMAL => 'decimal',
MYSQLI_TYPE_TINY => 'tinyint',
MYSQLI_TYPE_SHORT => 'int',
MYSQLI_TYPE_LONG => 'int',
MYSQLI_TYPE_FLOAT => 'float',
MYSQLI_TYPE_DOUBLE => 'double',
// MYSQLI_TYPE_NULL => 'DEFAULT NULL', // let flags handle it
MYSQLI_TYPE_TIMESTAMP => 'timestamp',
MYSQLI_TYPE_LONGLONG => 'bigint',
MYSQLI_TYPE_INT24 => 'mediumint',
MYSQLI_TYPE_DATE => 'date',
MYSQLI_TYPE_TIME => 'time',
MYSQLI_TYPE_DATETIME => 'datetime',
MYSQLI_TYPE_YEAR => 'year',
MYSQLI_TYPE_NEWDATE => 'date',
MYSQLI_TYPE_ENUM => 'enum',
MYSQLI_TYPE_SET => 'set',
MYSQLI_TYPE_TINY_BLOB => 'tinyblob',
MYSQLI_TYPE_MEDIUM_BLOB => 'mediumblob',
MYSQLI_TYPE_LONG_BLOB => 'longblob',
MYSQLI_TYPE_BLOB => 'blob',
MYSQLI_TYPE_VAR_STRING => 'varchar',
MYSQLI_TYPE_STRING => 'char',
MYSQLI_TYPE_GEOMETRY => 'geometry',
)
(line 83)

Array for converting MYSQLI_TYPE_* constants to text values

  • since: Property available since Release 1.6.5
  • access: public
mixed $num_rows = array() (line 49)
mixed $phptype (line 46)

Redefinition of:
DB_common::$phptype
DB type (mysql, oci8, odbc etc.)
mixed $prepare_tokens = array() (line 47)

Redefinition of:
DB_common::$prepare_tokens
mixed $prepare_types = array() (line 48)

Redefinition of:
DB_common::$prepare_types
mixed $transaction_opcount = 0 (line 50)
mixed $_db = false (line 53)

Inherited Variables

Inherited from DB_common

DB_common::$dbh
DB_common::$errorcode_map
DB_common::$features
DB_common::$fetchmode_object_class
DB_common::$last_query
DB_common::$options
DB_common::$prepared_queries
DB_common::$prepare_maxstmt
Methods
Constructor DB_mysqli (line 118)

DB_mysql constructor.

  • access: public
DB_mysqli DB_mysqli ()
affectedRows (line 498)

Gets the number of rows affected by the data manipulation query. For other queries, this function returns 0.

  • return: number of rows affected by the last query
integer affectedRows ()

Redefinition of:
DB_common::affectedRows()
Returns the affected rows of a query
autoCommit (line 433)

Enable/disable automatic commits.

void autoCommit ([mixed $onoff = false])

Redefinition of:
DB_common::autoCommit()
enable automatic Commit
commit (line 447)

Commit the current transaction.

void commit ()

Redefinition of:
DB_common::commit()
starts a Commit
connect (line 163)

Connect to a database and log in as the specified user.

  • return: DB_OK on success, a DB error on failure
  • access: public
mixed connect (mixed $dsninfo, [boolean $persistent = false], string $dsn)
  • string $dsn: the data source name (see DB::parseDSN for syntax)
  • boolean $persistent: (optional) whether the connection should be persistent
createSequence (line 621)

Creates a new sequence

int createSequence (string $seq_name)
  • string $seq_name: name of the new sequence

Redefinition of:
DB_common::createSequence()
Creates a new sequence
disconnect (line 235)

Log out and disconnect from the database.

  • return: true on success, false if not connected
  • access: public
boolean disconnect ()
dropSequence (line 648)

Deletes a sequence

int dropSequence (string $seq_name)
  • string $seq_name: name of the sequence to be deleted

Redefinition of:
DB_common::dropSequence()
Deletes a sequence
errorNative (line 517)

Get the native error code of the last error (if any) that occured on the current connection.

  • return: native MySQL error code
  • access: public
int errorNative ()

Redefinition of:
DB_common::errorNative()
Returns an errormessage, provides by the database
escapeSimple (line 736)

Escape a string according to the current DBMS's standards

  • return: the escaped string
  • internal:
string escapeSimple (string $str)
  • string $str: the string to be escaped

Redefinition of:
DB_common::escapeSimple()
Escape a string according to the current DBMS's standards
fetchInto (line 331)

Fetch a row and insert the data into an existing array.

Formating of the array and the data therein are configurable. See DB_result::fetchInto() for more information.

  • return: DB_OK on success, null when end of result set is reached or on failure
  • access: private
  • see: DB_result::fetchInto()
mixed fetchInto (resource $result, array &$arr, int $fetchmode, [int $rownum = null])
  • resource $result: query result identifier
  • array $arr: (reference) array where data from the row should be placed
  • int $fetchmode: how the resulting array should be indexed
  • int $rownum: the row number to fetch
freeResult (line 377)

Free the internal resources associated with $result.

  • return: true on success, false if $result is invalid
  • access: public
bool freeResult (resource $result)
  • resource $result: MySQL result identifier
getSpecialQuery (line 919)

Returns the query needed to get some backend info.

  • return: The SQL query string
string getSpecialQuery (string $type)
  • string $type: What kind of info you want to retrieve

Redefinition of:
DB_common::getSpecialQuery()
Returns the query needed to get some backend info
modifyLimitQuery (line 751)
void modifyLimitQuery (mixed $query, mixed $from, mixed $count, [mixed $params = array()])

Redefinition of:
DB_common::modifyLimitQuery()
This method is used by backends to alter limited queries
modifyQuery (line 743)
void modifyQuery (mixed $query)

Redefinition of:
DB_common::modifyQuery()
This method is used by backends to alter queries for various reasons
mysqlRaiseError (line 773)

Gather information about an error, then use that info to create a DB error object and finally return that object.

object DB mysqlRaiseError ([integer $errno = null])
  • integer $errno: PEAR error number (usually a DB constant) if manually raising an error
nextId (line 538)

Returns the next free id in a sequence

  • return: the next id number in the sequence. DB_Error if problem.
  • access: public
  • see: DB_common::nextID()
  • internal:
int nextId (string $seq_name, [boolean $ondemand = true])
  • string $seq_name: name of the sequence
  • boolean $ondemand: when true, the seqence is automatically created if it does not exist

Redefinition of:
DB_common::nextId()
Returns the next free id in a sequence
nextResult (line 305)

Move the internal mysql result pointer to the next available result.

This method has not been implemented yet.

  • access: public
false nextResult (resource $result)
  • resource $result: a valid sql result resource
numCols (line 397)

Get the number of columns in a result set.

  • return: the number of columns per row in $result
  • access: public
int numCols ($result $result)
  • $result $result: MySQL result identifier
numRows (line 418)

Get the number of rows in a result set.

  • return: the number of rows in $result
  • access: public
int numRows (resource $result)
  • resource $result: MySQL result identifier

Redefinition of:
DB_common::numRows()
Returns the number of rows in a result object
quoteIdentifier (line 719)

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

Quoting style depends on which database driver is being used.

MySQL can't handle the backtick character (`) in table or column names.

  • return: quoted identifier string
  • internal:
  • access: public
  • since: 1.6.0
string quoteIdentifier (string $str)
  • string $str: identifier name to be quoted

Redefinition of:
DB_common::quoteIdentifier()
Quote a string so it can be safely used as a table or column name
rollback (line 471)

Roll back (undo) the current transaction.

void rollback ()

Redefinition of:
DB_common::rollback()
starts a rollback
simpleQuery (line 255)

Send a query to MySQL and return the results as a MySQL resource identifier.

  • return: a valid MySQL result for successful SELECT queries, DB_OK for other successful queries. A DB error is returned on failure.
  • access: public
mixed simpleQuery (string $query)
  • string $query: the SQL query
tableInfo (line 811)

Returns information about a table or a result set.

WARNING: this method will probably not work because the mysqli_*() functions it relies upon may not exist.

  • return: an associative array with the information requested or an error object if something is wrong
  • see: DB_common::tableInfo()
  • internal:
  • access: public
array tableInfo (object|string $result, [int $mode = null])
  • object|string $result: DB_result object from a query or a string containing the name of a table
  • int $mode: a valid tableInfo mode

Redefinition of:
DB_common::tableInfo()
Returns information about a table or a result set
_BCsequence (line 663)

Backwards compatibility with old sequence emulation implementation (clean up the dupes).

  • return: DB_Error or true
mixed _BCsequence (string $seqname)
  • string $seqname: The sequence name to clean up

Inherited Methods

Inherited From DB_common

 DB_common::DB_common()
 DB_common::affectedRows()
 DB_common::autoCommit()
 DB_common::autoExecute()
 DB_common::autoPrepare()
 DB_common::buildManipSQL()
 DB_common::commit()
 DB_common::createSequence()
 DB_common::dropSequence()
 DB_common::errorCode()
 DB_common::errorMessage()
 DB_common::errorNative()
 DB_common::escapeSimple()
 DB_common::execute()
 DB_common::executeEmulateQuery()
 DB_common::executeMultiple()
 DB_common::freePrepared()
 DB_common::getAll()
 DB_common::getAssoc()
 DB_common::getCol()
 DB_common::getListOf()
 DB_common::getOne()
 DB_common::getOption()
 DB_common::getRow()
 DB_common::getSequenceName()
 DB_common::getSpecialQuery()
 DB_common::getTables()
 DB_common::limitQuery()
 DB_common::modifyLimitQuery()
 DB_common::modifyQuery()
 DB_common::nextId()
 DB_common::numRows()
 DB_common::prepare()
 DB_common::provides()
 DB_common::query()
 DB_common::quote()
 DB_common::quoteIdentifier()
 DB_common::quoteSmart()
 DB_common::quoteString()
 DB_common::raiseError()
 DB_common::rollback()
 DB_common::setFetchMode()
 DB_common::setOption()
 DB_common::tableInfo()
 DB_common::toString()
 DB_common::_convertNullArrayValuesToEmpty()
 DB_common::_rtrimArrayValues()

Documentation generated on Fri, 3 Dec 2004 12:27:03 +0000 by phpDocumentor 1.3.0RC3