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 = '', bool $pconn = false) 
inherited

Arguments

$db_dsnw

string

DSN for read/write operations

$db_dsnr

string

Optional DSN for read only operations

$pconn

bool

Enables persistent connections

Driver-specific configuration of database connection

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

Arguments

$dsn

array

DSN for DB connections

$dbh

\PDO

Connection handler

Abstract SQL statement for value concatenation

concat() : string
inherited

Response

string

SQL statement to be used in query

Returns PDO DSN string from DSN array

dsn_string(array $dsn) : string
inherited

Arguments

$dsn

array

DSN parameters

Response

string

DSN string

Returns driver-specific connection options

dsn_options(array $dsn) : array
inherited

Arguments

$dsn

array

DSN parameters

Response

array

Connection options

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

Factory, returns driver-specific instance of the class

factory(string $db_dsnw, string $db_dsnr = '', bool $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

bool

Enables persistent connections

Response

\rcube_db

Object instance

Connect to specific database

dsn_connect(array $dsn, string $mode) 
inherited

Arguments

$dsn

array

DSN for DB connections

$mode

string

Connection mode (r|w)

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

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

dsn_select($query) 
inherited

Arguments

$query

Activate/deactivate debug mode

set_debug(boolean $dbg = true) 
inherited

Arguments

$dbg

boolean

True if SQL queries should be logged

Writes debug information/query to 'sql' log file

debug(string $query) 
inherited

Arguments

$query

string

SQL query

Getter for error state

is_error(mixed $result = null) : string
inherited

Arguments

$result

mixed

Optional query result

Response

string

Error message

Connection state checker

is_connected() : boolean
inherited

Response

boolean

True if in connected state

Is database replication configured?

is_replicated() : bool
inherited

Response

bool

Returns true if dsnw != dsnr

Execute a SQL query

query() : \number
inherited

Response

\number

Query handle identifier

Execute a SQL query with limits

limitquery() : \PDOStatement|bool
inherited

Response

\PDOStatement|bool

Query handle or False on error

Execute a SQL query with limits

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

Arguments

$query

string

SQL query to execute

$offset

int

Offset for LIMIT statement

$numrows

int

Number of rows for LIMIT statement

$params

array

Values to be inserted in query

Response

\PDOStatement|bool

Query handle or False on error

Get number of affected rows for the last query

affected_rows(mixed $result = null) : int
inherited

Arguments

$result

mixed

Optional query handle

Response

int

Number of (matching) rows

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

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

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

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 col values for a result row

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

Arguments

$result

mixed

Optional query handle

$mode

int

Fetch mode identifier

Response

mixed

Array with col values or false on failure

Adds LIMIT,OFFSET clauses to the query

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

Arguments

$query

string

SQL query

$limit

int

Number of rows

$offset

int

Offset

Response

string

SQL query

Returns list of tables in a database

list_tables() : array
inherited

Response

array

List of all tables of the current database

Returns list of columns in database table

list_cols(string $table) : array
inherited

Arguments

$table

string

Table name

Response

array

List of table cols

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

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

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

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

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

Return SQL function for current time and date

now(int $interval) : string
inherited

Arguments

$interval

int

Optional interval (in seconds) to add/subtract

Response

string

SQL function to use in query

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

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

Return SQL statement to convert from a unix timestamp

fromunixtime(int $timestamp) : string
inherited

Arguments

$timestamp

int

Unix timestamp

Response

string

Date string in db-specific format

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

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

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

Arguments

$input

mixed

Data to fix

$serialized

bool

Enable serialization

Response

mixed

Properly UTF-8 encoded data

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

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

Arguments

$input

mixed

Input data

$serialized

bool

Enable serialization

Response

mixed

Decoded data

Return correct name for a specific database table

table_name(string $table) : string
inherited

Arguments

$table

string

Table name

Response

string

Translated table name

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

MDB2 DSN string parser

parse_dsn($dsn) : array
inherited static

Arguments

$dsn

Response

array

DSN parameters

Constants

DEBUG_LINE_LENGTH

DEBUG_LINE_LENGTH
inherited

Properties

db_provider

db_provider : 
inherited

db_dsnw

db_dsnw : 
inherited

db_dsnr

db_dsnr : 
inherited

db_connected

db_connected : 
inherited

db_mode

db_mode : 
inherited

db_table_dsn_map

db_table_dsn_map : 
inherited

dbh

dbh : 
inherited

dbhs

dbhs : 
inherited

table_connections

table_connections : 
inherited

db_error

db_error : 
inherited

db_error_msg

db_error_msg : 
inherited

conn_failure

conn_failure : 
inherited

db_index

db_index : 
inherited

last_result

last_result : 
inherited

tables

tables : 
inherited

variables

variables : 
inherited

options

options : 
inherited