class DatabaseInterface

Main interface for database interactions

Constants

QUERY_STORE

Force STORE_RESULT method, ignored by classic MySQL.

QUERY_UNBUFFERED

Do not read whole query.

GETVAR_SESSION

Get session variable.

GETVAR_GLOBAL

Get global variable.

CONNECT_USER

User connection.

CONNECT_CONTROL

Control user connection.

CONNECT_AUXILIARY

Auxiliary connection.

Used for example for replication setup.

Properties

Types $types

Methods

__construct(DbiExtension $ext)

Constructor

static bool
checkDbExtension(string $extension = 'mysqli')

Checks whether database extension is loaded

mixed
query(string $query, mixed $link = DatabaseInterface::CONNECT_USER, int $options = 0, bool $cache_affected_rows = true)

runs a query

mixed
getCachedTableContent(array $contentPath, mixed $default = null)

Get a cached value from table cache.

void
cacheTableContent(array|null $contentPath, mixed $value)

Set an item in table cache using dot notation.

void
clearTableCache()

Clear the table cache.

mixed
tryQuery(string $query, mixed $link = DatabaseInterface::CONNECT_USER, int $options = 0, bool $cache_affected_rows = true)

runs a query and returns the result

mysqli_result[]|boolean
tryMultiQuery(string $multiQuery = '', int $linkIndex = DatabaseInterface::CONNECT_USER)

Run multi query statement and return results

array
getTables(string $database, mixed $link = DatabaseInterface::CONNECT_USER)

returns array with table names for given db

array
getForeignKeyConstrains(string $database, array $tables, int $link = DatabaseInterface::CONNECT_USER)

returns

array
getTablesFull(string $database, string|array $table = '', bool $tbl_is_group = false, int $limit_offset = 0, boolean|integer $limit_count = false, string $sort_by = 'Name', string $sort_order = 'ASC', string|null $table_type = null, mixed $link = DatabaseInterface::CONNECT_USER)

returns array of all tables in given db or dbs this function expects unquoted names: RIGHT: my_database WRONG: my_database WRONG: my_database if $tbl_is_group is true, $table is used as filter for table names

array
getVirtualTables(string $db)

Get VIEWs in a particular database

array
getDatabasesFull(string|null $database = null, bool $force_stats = false, integer $link = DatabaseInterface::CONNECT_USER, string $sort_by = 'SCHEMA_NAME', string $sort_order = 'ASC', int $limit_offset = 0, bool|int $limit_count = false)

returns array with databases containing extended infos about them

array
getColumnMapFromSql(string $sql_query, array $view_columns = [])

returns detailed array with all columns for sql

array
getColumnsFull(string|null $database = null, string|null $table = null, string|null $column = null, mixed $link = DatabaseInterface::CONNECT_USER)

returns detailed array with all columns for given table in database, or all tables/databases

string
getColumnsSql(string $database, string $table, string|null $column = null, bool $full = false)

Returns SQL query for fetching columns for a table

array
getColumns(string $database, string $table, string|null $column = null, bool $full = false, integer $link = DatabaseInterface::CONNECT_USER)

Returns descriptions of columns in given table (all or given by $column)

array|null
getColumnNames(string $database, string $table, mixed $link = DatabaseInterface::CONNECT_USER)

Returns all column names in given table

string
getTableIndexesSql(string $database, string $table, string|null $where = null)

Returns SQL for fetching information on table indexes (SHOW INDEXES)

array
getTableIndexes(string $database, string $table, mixed $link = DatabaseInterface::CONNECT_USER)

Returns indexes of a table

mixed
getVariable(string $var, int $type = self::GETVAR_SESSION, mixed $link = DatabaseInterface::CONNECT_USER)

returns value of given mysql server variable

bool
setVariable(string $var, string $value, mixed $link = DatabaseInterface::CONNECT_USER)

Sets new value for a variable if it is different from the current value

static int
versionToInt(string $version)

Convert version string to integer.

void
postConnect()

Function called just after a connection to the MySQL database server has been established. It sets the connection collation, and determines the version of MySQL which is running.

void
setCollation(string $collation)

Sets collation connection for user link

void
postConnectControl()

Function called just after a connection to the MySQL database server has been established. It sets the connection collation, and determines the version of MySQL which is running.

mixed
fetchValue(string $query, int $row_number = 0, integer|string $field = 0, integer $link = DatabaseInterface::CONNECT_USER)

returns a single value from the given result or query, if the query or the result has more than one row or field the first field of the first row is returned

array|boolean
fetchSingleRow(string $query, string $type = 'ASSOC', integer $link = DatabaseInterface::CONNECT_USER)

returns only the first row from the result

array
fetchResult(string $query, string|integer|array $key = null, string|integer $value = null, integer $link = DatabaseInterface::CONNECT_USER, int $options = 0)

returns all rows in the resultset in one array

array
getCompatibilities()

Get supported SQL compatibility modes

array
getWarnings(integer $link = DatabaseInterface::CONNECT_USER)

returns warnings for last query

array
getProceduresOrFunctions(string $db, string $which, integer $link = DatabaseInterface::CONNECT_USER)

returns an array of PROCEDURE or FUNCTION names for a db

string|null
getDefinition(string $db, string $which, string $name, integer $link = DatabaseInterface::CONNECT_USER)

returns the definition of a specific PROCEDURE, FUNCTION, EVENT or VIEW

array
getRoutines(string $db, string|null $which = null, string $name = '')

returns details about the PROCEDUREs or FUNCTIONs for a specific database or details about a specific routine

array
getEvents(string $db, string $name = '')

returns details about the EVENTs for a specific database

array
getTriggers(string $db, string $table = '', string $delimiter = '//')

returns details about the TRIGGERs for a specific table or database

static string
formatError(int $error_number, string $error_message)

Formats database error message in a friendly way.

string
getCurrentUser()

gets the current user with host

bool
isSuperuser()

Checks if current user is superuser

bool
isUserType(string $type)

Checks if current user has global create user/grant privilege or is a superuser (i.e. SELECT on mysql.users) while caching the result in session.

array
getCurrentUserAndHost()

Get the current user and host

string|bool
getLowerCaseNames()

Returns value for lower_case_table_names variable

array
getSystemSchemas()

Get the list of system schemas

bool
isSystemSchema(string $schema_name, bool $testForMysqlSchema = false)

Checks whether given schema is a system schema

array
getConnectionParams(int $mode, array|null $server = null)

Return connection parameters for the database server

mixed
connect(int $mode, array|null $server = null, int|null $target = null)

connects to the database server

bool
selectDb(string $dbname, integer $link = DatabaseInterface::CONNECT_USER)

selects given database

array
fetchArray(object $result)

returns array of rows with associative and numeric keys from $result

array|bool
fetchAssoc(object $result)

returns array of rows with associative keys from $result

array|bool
fetchRow(object $result)

returns array of rows with numeric keys from $result

bool
dataSeek(object $result, int $offset)

Adjusts the result pointer to an arbitrary row in the result

void
freeResult(object $result)

Frees memory associated with the result

bool
moreResults(integer $link = DatabaseInterface::CONNECT_USER)

Check if there are any more query results from a multi query

bool
nextResult(integer $link = DatabaseInterface::CONNECT_USER)

Prepare next result from multi_query

mixed
storeResult(integer $link = DatabaseInterface::CONNECT_USER)

Store the result returned from multi query

string|bool
getHostInfo(integer $link = DatabaseInterface::CONNECT_USER)

Returns a string representing the type of connection used

int|bool
getProtoInfo(integer $link = DatabaseInterface::CONNECT_USER)

Returns the version of the MySQL protocol used

string
getClientInfo(integer $link = DatabaseInterface::CONNECT_USER)

returns a string that represents the client library version

string|bool
getError(integer $link = DatabaseInterface::CONNECT_USER)

returns last error message or false if no errors occurred

string|int
numRows(object $result)

returns the number of rows returned by last query

int|boolean
insertId(integer $link = DatabaseInterface::CONNECT_USER)

returns last inserted auto_increment id for given $link or $GLOBALS['userlink']

int|boolean
affectedRows(integer $link = DatabaseInterface::CONNECT_USER, bool $get_from_cache = true)

returns the number of rows affected by last query

mixed
getFieldsMeta(object $result)

returns metainfo for fields in $result

int
numFields(object $result)

return number of fields in given $result

int|bool
fieldLen(object $result, int $i)

returns the length of the given field $i in $result

string
fieldName(object $result, int $i)

returns name of $i. field in $result

string
fieldFlags(object $result, int $i)

returns concatenated string of human readable field flags

string
escapeString(string $str, mixed $link = DatabaseInterface::CONNECT_USER)

returns properly escaped string for use in MySQL queries

bool
isAmazonRds()

Checks if this database server is running on Amazon RDS.

string
getKillQuery(int $process)

Gets SQL for killing a process.

getSystemDatabase()

Get the phpmyadmin database manager

getTable(string $db_name, string $table_name)

Get a table with database name and table name

string
getDbCollation(string $db)

returns collation of given db

string
getServerCollation()

returns default server collation from show variables

int
getVersion()

Server version as number

string
getVersionString()

Server version

string
getVersionComment()

Server version comment

bool
isMariaDB()

Whether connection is MariaDB

bool
isPercona()

Whether connection is Percona

load(DbiExtension|null $extension = null)

Load correct database driver

object|false
prepare(string $query, int $link = DatabaseInterface::CONNECT_USER)

Prepare an SQL statement for execution.

Details

at line 119
__construct(DbiExtension $ext)

Constructor

Parameters

DbiExtension $ext Object to be used for database queries

at line 140
static bool checkDbExtension(string $extension = 'mysqli')

Checks whether database extension is loaded

Parameters

string $extension mysql extension to check

Return Value

bool

at line 155
mixed query(string $query, mixed $link = DatabaseInterface::CONNECT_USER, int $options = 0, bool $cache_affected_rows = true)

runs a query

Parameters

string $query SQL query to execute
mixed $link optional database link to use
int $options optional query options
bool $cache_affected_rows whether to cache affected rows

Return Value

mixed

at line 175
mixed getCachedTableContent(array $contentPath, mixed $default = null)

Get a cached value from table cache.

Parameters

array $contentPath Array of the name of the target value
mixed $default Return value on cache miss

Return Value

mixed cached value or default

at line 188
void cacheTableContent(array|null $contentPath, mixed $value)

Set an item in table cache using dot notation.

Parameters

array|null $contentPath Array with the target path
mixed $value Target value

Return Value

void

at line 218
void clearTableCache()

Clear the table cache.

Return Value

void

at line 300
mixed tryQuery(string $query, mixed $link = DatabaseInterface::CONNECT_USER, int $options = 0, bool $cache_affected_rows = true)

runs a query and returns the result

Parameters

string $query query to run
mixed $link link type
int $options query options
bool $cache_affected_rows whether to cache affected row

Return Value

mixed

at line 359
mysqli_result[]|boolean tryMultiQuery(string $multiQuery = '', int $linkIndex = DatabaseInterface::CONNECT_USER)

Run multi query statement and return results

Parameters

string $multiQuery multi query statement to execute
int $linkIndex index of the opened database link

Return Value

mysqli_result[]|boolean (false)

at line 377
array getTables(string $database, mixed $link = DatabaseInterface::CONNECT_USER)

returns array with table names for given db

Parameters

string $database name of database
mixed $link mysql link resource|object

Return Value

array tables names

at line 402
array getForeignKeyConstrains(string $database, array $tables, int $link = DatabaseInterface::CONNECT_USER)

returns

Parameters

string $database name of database
array $tables list of tables to search for for relations
int $link mysql link resource|object

Return Value

array array of found foreign keys

at line 551
array getTablesFull(string $database, string|array $table = '', bool $tbl_is_group = false, int $limit_offset = 0, boolean|integer $limit_count = false, string $sort_by = 'Name', string $sort_order = 'ASC', string|null $table_type = null, mixed $link = DatabaseInterface::CONNECT_USER)

returns array of all tables in given db or dbs this function expects unquoted names: RIGHT: my_database WRONG: my_database WRONG: my_database if $tbl_is_group is true, $table is used as filter for table names

$dbi->getTablesFull('my_database'); $dbi->getTablesFull('my_database', 'my_table')); $dbi->getTablesFull('my_database', 'my_tables_', true));

Parameters

string $database database
string|array $table table name(s)
bool $tbl_is_group $table is a table group
int $limit_offset zero-based offset for the count
boolean|integer $limit_count number of tables to return
string $sort_by table attribute to sort by
string $sort_order direction to sort (ASC or DESC)
string|null $table_type whether table or view
mixed $link link type

Return Value

array list of tables in given db(s)

at line 839
array getVirtualTables(string $db)

Get VIEWs in a particular database

Parameters

string $db Database name to look in

Return Value

array Set of VIEWs inside the database

at line 871
array getDatabasesFull(string|null $database = null, bool $force_stats = false, integer $link = DatabaseInterface::CONNECT_USER, string $sort_by = 'SCHEMA_NAME', string $sort_order = 'ASC', int $limit_offset = 0, bool|int $limit_count = false)

returns array with databases containing extended infos about them

Parameters

string|null $database database
bool $force_stats retrieve stats also for MySQL < 5
integer $link link type
string $sort_by column to order by
string $sort_order ASC or DESC
int $limit_offset starting offset for LIMIT
bool|int $limit_count row count for LIMIT or true for $GLOBALS['cfg']['MaxDbList']

Return Value

array

at line 1088
array getColumnMapFromSql(string $sql_query, array $view_columns = [])

returns detailed array with all columns for sql

Parameters

string $sql_query target SQL query to get columns
array $view_columns alias for columns

Return Value

array

at line 1134
array getColumnsFull(string|null $database = null, string|null $table = null, string|null $column = null, mixed $link = DatabaseInterface::CONNECT_USER)

returns detailed array with all columns for given table in database, or all tables/databases

Parameters

string|null $database name of database
string|null $table name of table to retrieve columns from
string|null $column name of specific column
mixed $link mysql link resource

Return Value

array

at line 1289
string getColumnsSql(string $database, string $table, string|null $column = null, bool $full = false)

Returns SQL query for fetching columns for a table

The 'Key' column is not calculated properly, use $dbi->getColumns() to get correct values.

Parameters

string $database name of database
string $table name of table to retrieve columns from
string|null $column name of column, null to show all columns
bool $full whether to return full info or only column names

Return Value

string

See also

at line 1315
array getColumns(string $database, string $table, string|null $column = null, bool $full = false, integer $link = DatabaseInterface::CONNECT_USER)

Returns descriptions of columns in given table (all or given by $column)

Parameters

string $database name of database
string $table name of table to retrieve columns from
string|null $column name of column, null to show all columns
bool $full whether to return full info or only column names
integer $link link type

Return Value

array array indexed by column names or, if $column is given, flat array description

at line 1363
array|null getColumnNames(string $database, string $table, mixed $link = DatabaseInterface::CONNECT_USER)

Returns all column names in given table

Parameters

string $database name of database
string $table name of table to retrieve columns from
mixed $link mysql link resource

Return Value

array|null

at line 1387
string getTableIndexesSql(string $database, string $table, string|null $where = null)

Returns SQL for fetching information on table indexes (SHOW INDEXES)

Parameters

string $database name of database
string $table name of the table whose indexes are to be retrieved
string|null $where additional conditions for WHERE

Return Value

string SQL for getting indexes

at line 1409
array getTableIndexes(string $database, string $table, mixed $link = DatabaseInterface::CONNECT_USER)

Returns indexes of a table

Parameters

string $database name of database
string $table name of the table whose indexes are to be retrieved
mixed $link mysql link resource

Return Value

array

at line 1433
mixed getVariable(string $var, int $type = self::GETVAR_SESSION, mixed $link = DatabaseInterface::CONNECT_USER)

returns value of given mysql server variable

Parameters

string $var mysql server variable name
int $type DatabaseInterface::GETVAR_SESSION | DatabaseInterface::GETVAR_GLOBAL
mixed $link mysql link resource|object

Return Value

mixed value for mysql server variable

at line 1465
bool setVariable(string $var, string $value, mixed $link = DatabaseInterface::CONNECT_USER)

Sets new value for a variable if it is different from the current value

Parameters

string $var variable name
string $value value to set
mixed $link mysql link resource|object

Return Value

bool whether query was a successful

at line 1489
static int versionToInt(string $version)

Convert version string to integer.

Parameters

string $version MySQL server version

Return Value

int

at line 1502
void postConnect()

Function called just after a connection to the MySQL database server has been established. It sets the connection collation, and determines the version of MySQL which is running.

Return Value

void

at line 1590
void setCollation(string $collation)

Sets collation connection for user link

Parameters

string $collation collation to set

Return Value

void

at line 1621
void postConnectControl()

Function called just after a connection to the MySQL database server has been established. It sets the connection collation, and determines the version of MySQL which is running.

Return Value

void

at line 1665
mixed fetchValue(string $query, int $row_number = 0, integer|string $field = 0, integer $link = DatabaseInterface::CONNECT_USER)

returns a single value from the given result or query, if the query or the result has more than one row or field the first field of the first row is returned

$sql = 'SELECT name FROM user WHERE id = 123'; $user_name = $dbi->fetchValue($sql); // produces // $user_name = 'John Doe'

Parameters

string $query The query to execute
int $row_number row to fetch the value from, starting at 0, with 0 being default
integer|string $field field to fetch the value from, starting at 0, with 0 being default
integer $link link type

Return Value

mixed value of first field in first row from result or false if not found

at line 1728
array|boolean fetchSingleRow(string $query, string $type = 'ASSOC', integer $link = DatabaseInterface::CONNECT_USER)

returns only the first row from the result

$sql = 'SELECT * FROM user WHERE id = 123'; $user = $dbi->fetchSingleRow($sql); // produces // $user = array('id' => 123, 'name' => 'John Doe')

Parameters

string $query The query to execute
string $type NUM|ASSOC|BOTH returned array should either numeric associative or both
integer $link link type

Return Value

array|boolean first row from result or false if result is empty

at line 1836
array fetchResult(string $query, string|integer|array $key = null, string|integer $value = null, integer $link = DatabaseInterface::CONNECT_USER, int $options = 0)

returns all rows in the resultset in one array

$sql = 'SELECT * FROM user'; $users = $dbi->fetchResult($sql); // produces // $users[] = array('id' => 123, 'name' => 'John Doe')

$sql = 'SELECT id, name FROM user'; $users = $dbi->fetchResult($sql, 'id'); // produces // $users['123'] = array('id' => 123, 'name' => 'John Doe')

$sql = 'SELECT id, name FROM user'; $users = $dbi->fetchResult($sql, 0); // produces // $users['123'] = array(0 => 123, 1 => 'John Doe')

$sql = 'SELECT id, name FROM user'; $users = $dbi->fetchResult($sql, 'id', 'name'); // or $users = $dbi->fetchResult($sql, 0, 1); // produces // $users['123'] = 'John Doe'

$sql = 'SELECT name FROM user'; $users = $dbi->fetchResult($sql); // produces // $users[] = 'John Doe'

$sql = 'SELECT group, name FROM user' $users = $dbi->fetchResult($sql, array('group', null), 'name'); // produces // $users['admin'][] = 'John Doe'

$sql = 'SELECT group, name FROM user' $users = $dbi->fetchResult($sql, array('group', 'name'), 'id'); // produces // $users['admin']['John Doe'] = '123'

Parameters

string $query query to execute
string|integer|array $key field-name or offset used as key for array or array of those
string|integer $value value-name or offset used as value for array
integer $link link type
int $options query options

Return Value

array resultrows or values indexed by $key

at line 1902
array getCompatibilities()

Get supported SQL compatibility modes

Return Value

array supported SQL compatibility modes

at line 1927
array getWarnings(integer $link = DatabaseInterface::CONNECT_USER)

returns warnings for last query

Parameters

integer $link link type

Return Value

array warnings

at line 1941
array getProceduresOrFunctions(string $db, string $which, integer $link = DatabaseInterface::CONNECT_USER)

returns an array of PROCEDURE or FUNCTION names for a db

Parameters

string $db db name
string $which PROCEDURE | FUNCTION
integer $link link type

Return Value

array the procedure names or function names

at line 1971
string|null getDefinition(string $db, string $which, string $name, integer $link = DatabaseInterface::CONNECT_USER)

returns the definition of a specific PROCEDURE, FUNCTION, EVENT or VIEW

Parameters

string $db db name
string $which PROCEDURE | FUNCTION | EVENT | VIEW
string $name the procedure|function|event|view name
integer $link link type

Return Value

string|null the definition

at line 2000
array getRoutines(string $db, string|null $which = null, string $name = '')

returns details about the PROCEDUREs or FUNCTIONs for a specific database or details about a specific routine

Parameters

string $db db name
string|null $which PROCEDURE | FUNCTION or null for both
string $name name of the routine (to fetch a specific routine)

Return Value

array information about ROCEDUREs or FUNCTIONs

at line 2091
array getEvents(string $db, string $name = '')

returns details about the EVENTs for a specific database

Parameters

string $db db name
string $name event name

Return Value

array information about EVENTs

at line 2155
array getTriggers(string $db, string $table = '', string $delimiter = '//')

returns details about the TRIGGERs for a specific table or database

Parameters

string $db db name
string $table table name
string $delimiter the delimiter to use (may be empty)

Return Value

array information about triggers (may be empty)

at line 2234
static string formatError(int $error_number, string $error_message)

Formats database error message in a friendly way.

This is needed because some errors messages cannot be obtained by mysql_error().

Parameters

int $error_number Error code
string $error_message Error message as returned by server

Return Value

string HML text with error details

at line 2288
string getCurrentUser()

gets the current user with host

Return Value

string the current user i.e. user@host

at line 2306
bool isSuperuser()

Checks if current user is superuser

Return Value

bool Whether user is a superuser

at line 2321
bool isUserType(string $type)

Checks if current user has global create user/grant privilege or is a superuser (i.e. SELECT on mysql.users) while caching the result in session.

Parameters

string $type type of user to check for i.e. 'create', 'grant', 'super'

Return Value

bool Whether user is a given type of user

at line 2409
array getCurrentUserAndHost()

Get the current user and host

Return Value

array array of username and hostname

at line 2430
string|bool getLowerCaseNames()

Returns value for lower_case_table_names variable

Return Value

string|bool

at line 2445
array getSystemSchemas()

Get the list of system schemas

Return Value

array list of system schemas

at line 2471
bool isSystemSchema(string $schema_name, bool $testForMysqlSchema = false)

Checks whether given schema is a system schema

Parameters

string $schema_name Name of schema (database) to test
bool $testForMysqlSchema Whether 'mysql' schema should be treated the same as IS and DD

Return Value

bool

at line 2491
array getConnectionParams(int $mode, array|null $server = null)

Return connection parameters for the database server

Parameters

int $mode Connection mode on of CONNECT_USER, CONNECT_CONTROL or CONNECT_AUXILIARY.
array|null $server Server information like host/port/socket/persistent

Return Value

array user, host and server settings array

at line 2595
mixed connect(int $mode, array|null $server = null, int|null $target = null)

connects to the database server

Parameters

int $mode Connection mode on of CONNECT_USER, CONNECT_CONTROL or CONNECT_AUXILIARY.
array|null $server Server information like host/port/socket/persistent
int|null $target How to store connection link, defaults to $mode

Return Value

mixed false on error or a connection object on success

at line 2657
bool selectDb(string $dbname, integer $link = DatabaseInterface::CONNECT_USER)

selects given database

Parameters

string $dbname database name to select
integer $link link type

Return Value

bool

at line 2672
array fetchArray(object $result)

returns array of rows with associative and numeric keys from $result

Parameters

object $result result set identifier

Return Value

array

at line 2684
array|bool fetchAssoc(object $result)

returns array of rows with associative keys from $result

Parameters

object $result result set identifier

Return Value

array|bool

at line 2696
array|bool fetchRow(object $result)

returns array of rows with numeric keys from $result

Parameters

object $result result set identifier

Return Value

array|bool

at line 2709
bool dataSeek(object $result, int $offset)

Adjusts the result pointer to an arbitrary row in the result

Parameters

object $result database result
int $offset offset to seek

Return Value

bool true on success, false on failure

at line 2721
void freeResult(object $result)

Frees memory associated with the result

Parameters

object $result database result

Return Value

void

at line 2733
bool moreResults(integer $link = DatabaseInterface::CONNECT_USER)

Check if there are any more query results from a multi query

Parameters

integer $link link type

Return Value

bool true or false

at line 2748
bool nextResult(integer $link = DatabaseInterface::CONNECT_USER)

Prepare next result from multi_query

Parameters

integer $link link type

Return Value

bool true or false

at line 2763
mixed storeResult(integer $link = DatabaseInterface::CONNECT_USER)

Store the result returned from multi query

Parameters

integer $link link type

Return Value

mixed false when empty results / result set when not empty

at line 2778
string|bool getHostInfo(integer $link = DatabaseInterface::CONNECT_USER)

Returns a string representing the type of connection used

Parameters

integer $link link type

Return Value

string|bool type of connection used

at line 2793
int|bool getProtoInfo(integer $link = DatabaseInterface::CONNECT_USER)

Returns the version of the MySQL protocol used

Parameters

integer $link link type

Return Value

int|bool version of the MySQL protocol used

at line 2808
string getClientInfo(integer $link = DatabaseInterface::CONNECT_USER)

returns a string that represents the client library version

Parameters

integer $link link type

Return Value

string MySQL client library version

at line 2823
string|bool getError(integer $link = DatabaseInterface::CONNECT_USER)

returns last error message or false if no errors occurred

Parameters

integer $link link type

Return Value

string|bool error or false

at line 2838
string|int numRows(object $result)

returns the number of rows returned by last query

Parameters

object $result result set identifier

Return Value

string|int

at line 2851
int|boolean insertId(integer $link = DatabaseInterface::CONNECT_USER)

returns last inserted auto_increment id for given $link or $GLOBALS['userlink']

Parameters

integer $link link type

Return Value

int|boolean

at line 2872
int|boolean affectedRows(integer $link = DatabaseInterface::CONNECT_USER, bool $get_from_cache = true)

returns the number of rows affected by last query

Parameters

integer $link link type
bool $get_from_cache whether to retrieve from cache

Return Value

int|boolean

at line 2894
mixed getFieldsMeta(object $result)

returns metainfo for fields in $result

Parameters

object $result result set identifier

Return Value

mixed meta info for fields in $result

at line 2924
int numFields(object $result)

return number of fields in given $result

Parameters

object $result result set identifier

Return Value

int field count

at line 2937
int|bool fieldLen(object $result, int $i)

returns the length of the given field $i in $result

Parameters

object $result result set identifier
int $i field

Return Value

int|bool length of field

at line 2950
string fieldName(object $result, int $i)

returns name of $i. field in $result

Parameters

object $result result set identifier
int $i field

Return Value

string name of $i. field in $result

at line 2963
string fieldFlags(object $result, int $i)

returns concatenated string of human readable field flags

Parameters

object $result result set identifier
int $i field

Return Value

string field flags

at line 2976
string escapeString(string $str, mixed $link = DatabaseInterface::CONNECT_USER)

returns properly escaped string for use in MySQL queries

Parameters

string $str string to be escaped
mixed $link optional database link to use

Return Value

string a MySQL escaped string

at line 2990
bool isAmazonRds()

Checks if this database server is running on Amazon RDS.

Return Value

bool

at line 3010
string getKillQuery(int $process)

Gets SQL for killing a process.

Parameters

int $process Process ID

Return Value

string

at line 3024
SystemDatabase getSystemDatabase()

Get the phpmyadmin database manager

Return Value

SystemDatabase

at line 3037
Table getTable(string $db_name, string $table_name)

Get a table with database name and table name

Parameters

string $db_name DB name
string $table_name Table name

Return Value

Table

at line 3049
string getDbCollation(string $db)

returns collation of given db

Parameters

string $db name of db

Return Value

string collation of $db

at line 3078
string getServerCollation()

returns default server collation from show variables

Return Value

string

at line 3088
int getVersion()

Server version as number

Return Value

int

at line 3098
string getVersionString()

Server version

Return Value

string

at line 3108
string getVersionComment()

Server version comment

Return Value

string

at line 3118
bool isMariaDB()

Whether connection is MariaDB

Return Value

bool

at line 3128
bool isPercona()

Whether connection is Percona

Return Value

bool

at line 3140
static DatabaseInterface load(DbiExtension|null $extension = null)

Load correct database driver

Parameters

DbiExtension|null $extension Force the use of an alternative extension

Return Value

DatabaseInterface

at line 3175
object|false prepare(string $query, int $link = DatabaseInterface::CONNECT_USER)

Prepare an SQL statement for execution.

Parameters

string $query The query, as a string.
int $link Link type.

Return Value

object|false A statement object or false.