rcube_db_mysql

Extends \rcube_db

Database independent query interface

This is a wrapper for the PHP PDO

package

Framework

subpackage

Database

Methods

Object constructor

__construct(string $db_dsnw, string $db_dsnr = '', boolean $pconn = false) 
inherited

Arguments

$db_dsnw

string

DSN for read/write operations

$db_dsnr

string

Optional DSN for read only operations

$pconn

boolean

Enables persistent connections

Get col values for a result row

_fetch_row(mixed $result, integer $mode) : mixed
inherited

Arguments

$result

mixed

Optional query handle

$mode

integer

Fetch mode identifier

Response

mixed

Array with col values or false on failure

Execute a SQL query with limits

_query(string $query, integer $offset, integer $numrows, array $params) : \PDOStatement|boolean
inherited

Arguments

$query

string

SQL query to execute

$offset

integer

Offset for LIMIT statement

$numrows

integer

Number of rows for LIMIT statement

$params

array

Values to be inserted in query

Response

\PDOStatement|boolean

Query handle or False on error

Get number of affected rows for the last query

affected_rows(mixed $result = null) : integer
inherited

Arguments

$result

mixed

Optional query handle

Response

integer

Number of (matching) rows

Return list of elements for use with SQL's IN clause

array2list(array $arr, string $type = null) : string
inherited

Arguments

$arr

array

Input array

$type

string

Type of data (integer, bool, ident)

Response

string

Comma-separated list of quoted values for use in query

Terminate database connection.

closeConnection() 
inherited

Abstract SQL statement for value concatenation

concat() : string
inherited

Response

string

SQL statement to be used in query

Driver-specific configuration of database connection

conn_configure(array $dsn, \PDO $dbh) 
inherited

Arguments

$dsn

array

DSN for DB connections

$dbh

\PDO

Connection handler

Create PDO connection

conn_create( $dsn) 
inherited

Arguments

$dsn

Driver-specific preparation of database connection

conn_prepare(array $dsn) 
inherited

Arguments

$dsn

array

DSN for DB connections

Connect to appropriate database depending on the operation

db_connect(string $mode, boolean $force = false) 
inherited

Arguments

$mode

string

Connection mode (r|w)

$force

boolean

Enforce using the given mode

Writes debug information/query to 'sql' log file

debug(string $query) 
inherited

Arguments

$query

string

SQL query

Decodes encoded UTF-8 string/object/array (recursive)

decode(mixed $input, boolean $serialized = false) : mixed
inherited static

Arguments

$input

mixed

Input data

$serialized

boolean

Enable serialization

Response

mixed

Decoded data

Connect to specific database

dsn_connect(array $dsn, string $mode) 
inherited

Arguments

$dsn

array

DSN for DB connections

$mode

string

Connection mode (r|w)

Returns driver-specific connection options

dsn_options(array $dsn) : array
inherited

Arguments

$dsn

array

DSN parameters

Response

array

Connection options

Analyze the given SQL statement and select the appropriate connection to use

dsn_select( $query) 
inherited

Arguments

$query

Returns PDO DSN string from DSN array

dsn_string(array $dsn) : string
inherited

Arguments

$dsn

array

DSN parameters

Response

string

DSN string

Encodes non-UTF-8 characters in string/array/object (recursive)

encode(mixed $input, boolean $serialized = false) : mixed
inherited static

Arguments

$input

mixed

Data to fix

$serialized

boolean

Enable serialization

Response

mixed

Properly UTF-8 encoded data

Commit transaction

endTransaction() : boolean
inherited

Response

boolean

True on success, False on failure

Escapes a string so it can be safely used in a query

escape(string $str) : string
inherited

Arguments

$str

string

A string to escape

Response

string

Escaped string for use in a query

Escapes a string so it can be safely used in a query

escapeSimple(string $str) : string
inherited
deprecated

Replaced by rcube_db::escape

see \rcube_db::escape

Arguments

$str

string

A string to escape

Response

string

Escaped string for use in a query

Execute the given SQL script

exec_script( $sql) : \boolen
inherited

Arguments

$sql

Response

\boolen

True on success, False on error

Factory, returns driver-specific instance of the class

factory(string $db_dsnw, string $db_dsnr = '', boolean $pconn = false) : \rcube_db
inherited static

Arguments

$db_dsnw

string

DSN for read/write operations

$db_dsnr

string

Optional DSN for read only operations

$pconn

boolean

Enables persistent connections

Response

\rcube_db

Object instance

Get an index array for one row If no query handle is specified, the last query will be taken as reference

fetch_array(mixed $result = null) : mixed
inherited

Arguments

$result

mixed

Optional query handle

Response

mixed

Array with col values or false on failure

Get an associative array for one row If no query handle is specified, the last query will be taken as reference

fetch_assoc(mixed $result = null) : mixed
inherited

Arguments

$result

mixed

Optional query handle

Response

mixed

Array with col values or false on failure

Parse SQL file and fix table names according to table prefix

fix_table_names( $sql) 
inherited

Arguments

$sql

Preg_replace callback for fix_table_names()

fix_table_names_callback( $matches) 
inherited

Arguments

$matches

Return SQL statement to convert from a unix timestamp

fromunixtime(integer $timestamp) : string
inherited

Arguments

$timestamp

integer

Unix timestamp

Response

string

Date string in db-specific format

Get database runtime variables

get_variable(string $varname, mixed $default = null) : mixed
inherited

Arguments

$varname

string

Variable name

$default

mixed

Default value if variable is not set

Response

mixed

Variable value or default

Helper method to handle DB errors.

handle_error( $query) : mixed
inherited

This by default logs the error but could be overriden by a driver implementation

Arguments

$query

Response

mixed

Result to be stored and returned

Return SQL statement for case insensitive LIKE

ilike(string $column, string $value) : string
inherited

Arguments

$column

string

Field name

$value

string

Search value

Response

string

SQL statement to use in query

Get last inserted record ID

insert_id(string $table = '') : mixed
inherited

Arguments

$table

string

Table name (to find the incremented sequence)

Response

mixed

ID or false on failure

Connection state checker

is_connected() : boolean
inherited

Response

boolean

True if in connected state

Getter for error state

is_error(mixed $result = null) : string
inherited

Arguments

$result

mixed

Optional query result

Response

string

Error message

Is database replication configured?

is_replicated() : boolean
inherited

Response

boolean

Returns true if dsnw != dsnr

Execute a SQL query with limits

limitquery() : \PDOStatement|boolean
inherited

Response

\PDOStatement|boolean

Query handle or False on error

Returns list of columns in database table

list_cols(string $table) : array
inherited

Arguments

$table

string

Table name

Response

array

List of table cols

Returns list of tables in a database

list_tables() : array
inherited

Response

array

List of all tables of the current database

Return SQL function for current time and date

now(integer $interval) : string
inherited

Arguments

$interval

integer

Optional interval (in seconds) to add/subtract

Response

string

SQL function to use in query

Get number of rows for a SQL query If no query handle is specified, the last query will be taken as reference

num_rows(mixed $result = null) : mixed
inherited
deprecated

This method shows very poor performance and should be avoided.

Arguments

$result

mixed

Optional query handle

Response

mixed

Number of rows or false on failure

MDB2 DSN string parser

parse_dsn( $dsn) : array
inherited static

Arguments

$dsn

Response

array

DSN parameters

Execute a SQL query

query() : \number
inherited

Response

\number

Query handle identifier

Query execution

query_execute( $query) 
inherited

Arguments

$query

Parse SQL query and replace identifier quoting

query_parse(string $query) : string
inherited

Arguments

$query

string

SQL query

Response

string

SQL query

Formats input so it can be safely used in a query

quote(mixed $input, string $type = null) : string
inherited

Arguments

$input

mixed

Value to quote

$type

string

Type of data (integer, bool, ident)

Response

string

Quoted/converted string for use in query

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

quote_identifier(string $str) : string
inherited

Arguments

$str

string

Value to quote

Response

string

Quoted string for use in query

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

quoteIdentifier(string $str) : string
inherited
deprecated

Replaced by rcube_db::quote_identifier

see \rcube_db::quote_identifier

Arguments

$str

string

Value to quote

Response

string

Quoted string for use in query

Rollback transaction

rollbackTransaction() : boolean
inherited

Response

boolean

True on success, False on failure

Activate/deactivate debug mode

set_debug(boolean $dbg = true) 
inherited

Arguments

$dbg

boolean

True if SQL queries should be logged

Adds LIMIT,OFFSET clauses to the query

set_limit(string $query, integer $limit, integer $offset) : string
inherited

Arguments

$query

string

SQL query

$limit

integer

Number of rows

$offset

integer

Offset

Response

string

SQL query

Set class option value

set_option(string $name, mixed $value) 
inherited

Arguments

$name

string

Option name

$value

mixed

Option value

Set DSN connection to be used for the given table

set_table_dsn( $table,  $mode) 
inherited

Arguments

$table

$mode

Start transaction

startTransaction() : boolean
inherited

Response

boolean

True on success, False on failure

Return correct name for a specific database table

table_name(string $table, boolean $quoted = false) : string
inherited

Arguments

$table

string

Table name

$quoted

boolean

Quote table identifier

Response

string

Translated table name

Return SQL statement to convert a field value into a unix timestamp

unixtimestamp(string $field) : string
inherited

This method is deprecated and should not be used anymore due to limitations of timestamp functions in Mysql (year 2038 problem)

deprecated

Arguments

$field

string

Field name

Response

string

SQL statement to use in query

Constants

DEBUG_LINE_LENGTH

DEBUG_LINE_LENGTH
inherited

DEFAULT_QUOTE

DEFAULT_QUOTE
inherited

Properties

db_provider

db_provider : 
inherited

Type(s)

db_dsnw

db_dsnw : 
inherited

Type(s)

db_dsnr

db_dsnr : 
inherited

Type(s)

db_connected

db_connected : 
inherited

Type(s)

db_mode

db_mode : 
inherited

Type(s)

dbh

dbh : 
inherited

Type(s)

dbhs

dbhs : 
inherited

Type(s)

table_connections

table_connections : 
inherited

Type(s)

db_error

db_error : 
inherited

Type(s)

db_error_msg

db_error_msg : 
inherited

Type(s)

conn_failure

conn_failure : 
inherited

Type(s)

db_index

db_index : 
inherited

Type(s)

last_result

last_result : 
inherited

Type(s)

tables

tables : 
inherited

Type(s)

variables

variables : 
inherited

Type(s)

options

options : 
inherited

Type(s)