Class rcube_db

Description

Database independent query interface.

This is a wrapper for the PHP PDO.

Located in /lib/Roundcube/rcube_db.php (line 26)


	
			
Direct descendents
Class Description
 class rcube_db_mssql Database independent query interface This is a wrapper for the PHP PDO
 class rcube_db_mysql Database independent query interface
 class rcube_db_pgsql Database independent query interface This is a wrapper for the PHP PDO
 class rcube_db_sqlite Database independent query interface This is a wrapper for the PHP PDO
 class rcube_db_sqlsrv Database independent query interface This is a wrapper for the PHP PDO
Variable Summary
 mixed $dbh
 mixed $db_dsnr
 mixed $db_dsnw
 mixed $db_error
 mixed $db_index
 mixed $db_mode
 mixed $db_provider
 mixed $last_result
 mixed $options
 mixed $tables
 mixed $variables
Method Summary
 static mixed decode (mixed $input)
 static mixed encode (mixed $input)
 static rcube_db factory (string $db_dsnw, [string $db_dsnr = ''], [bool $pconn = false])
 static array parse_dsn ( $dsn, string $sequence)
 rcube_db __construct (string $db_dsnw, [string $db_dsnr = ''], [bool $pconn = false])
 int affected_rows ([mixed $result = null])
 string array2list (array $arr, [string $type = null])
 string concat ()
 void conn_configure (array $dsn, PDO $dbh)
 void conn_prepare (array $dsn)
 void db_connect (string $mode)
 void debug (string $query)
 PDO dsn_connect (array $dsn)
 array dsn_options (array $dsn)
 string dsn_string (array $dsn)
 string escape (string $str)
 string escapeSimple (string $str)
 mixed fetch_array ([mixed $result = null])
 mixed fetch_assoc ([mixed $result = null])
 string fromunixtime (int $timestamp)
 mixed get_variable (string $varname, [mixed $default = null])
 string ilike (string $column, string $value)
 void init ()
 mixed insert_id ([string $table = ''])
 boolean is_connected ()
 string is_error ([mixed $result = null])
 bool is_replicated ()
 PDOStatement|bool limitquery (string 0, int 1, int 2, mixed 3)
 array list_cols (string $table)
 array list_tables ()
 string now ()
 mixed num_rows ([mixed $result = null])
 number query (string 0, mixed 1)
 string quote (mixed $input, [string $type = null])
 string quoteIdentifier (string $str)
 string quote_identifier (string $str)
 void set_charset (string $charset)
 void set_debug ([boolean $dbg = true])
 string set_limit (string $query, [int $limit = 0], [int $offset = 0])
 string table_name (string $table)
 string unixtimestamp (string $field)
 mixed _fetch_row (mixed $result, int $mode)
 PDOStatement|bool _query (string $query, int $offset, int $numrows, array $params)
Variables
mixed $conn_failure = false (line 38)
  • access: protected
mixed $dbh (line 34)
  • access: protected
mixed $db_connected = false (line 32)
  • access: protected
mixed $db_dsnr (line 31)
  • access: protected
mixed $db_dsnw (line 30)
  • access: protected
mixed $db_error = false (line 36)
  • access: protected
mixed $db_error_msg = '' (line 37)
  • access: protected
mixed $db_index = 0 (line 39)
  • access: protected
mixed $db_mode (line 33)
  • access: protected
mixed $last_result (line 40)
  • access: protected
mixed $options = array(
// column/table quotes
'identifier_start' => '"',
'identifier_end' => '"',
)
(line 44)
  • access: protected
mixed $tables (line 41)
  • access: protected
mixed $variables (line 42)
  • access: protected
Methods
static decode (line 821)

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

  • return: Decoded data
  • access: public
mixed decode (mixed $input)
  • mixed $input: Input data
static encode (line 796)

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

  • return: Properly UTF-8 encoded data
  • access: public
mixed encode (mixed $input)
  • mixed $input: Data to fix
static factory (line 60)

Factory, returns driver-specific instance of the class

  • return: Object instance
  • access: public
rcube_db factory (string $db_dsnw, [string $db_dsnr = ''], [bool $pconn = false])
  • string $db_dsnw: DSN for read/write operations
  • string $db_dsnr: Optional DSN for read only operations
  • bool $pconn: Enables persistent connections
static parse_dsn (line 865)

MDB2 DSN string parser

  • return: DSN parameters
  • access: public
array parse_dsn ( $dsn, string $sequence)
  • string $sequence: Secuence name
  • $dsn
Constructor __construct (line 90)

Object constructor

  • access: public
rcube_db __construct (string $db_dsnw, [string $db_dsnr = ''], [bool $pconn = false])
  • string $db_dsnw: DSN for read/write operations
  • string $db_dsnr: Optional DSN for read only operations
  • bool $pconn: Enables persistent connections
affected_rows (line 433)

Get number of affected rows for the last query

  • return: Number of (matching) rows
  • access: public
int affected_rows ([mixed $result = null])
  • mixed $result: Optional query handle
array2list (line 720)

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

  • return: Comma-separated list of quoted values for use in query
  • access: public
string array2list (array $arr, [string $type = null])
  • array $arr: Input array
  • string $type: Type of data (integer, bool, ident)
concat (line 779)

Abstract SQL statement for value concatenation

  • return: SQL statement to be used in query
  • access: public
string concat ()

Redefined in descendants as:
conn_configure (line 180)

Driver-specific configuration of database connection

  • access: protected
void conn_configure (array $dsn, PDO $dbh)
  • array $dsn: DSN for DB connections
  • PDO $dbh: Connection handler

Redefined in descendants as:
conn_prepare (line 170)

Driver-specific preparation of database connection

  • access: protected
void conn_prepare (array $dsn)
  • array $dsn: DSN for DB connections

Redefined in descendants as:
db_connect (line 199)

Connect to appropriate database depending on the operation

  • access: public
void db_connect (string $mode)
  • string $mode: Connection mode (r|w)
debug (line 255)

Writes debug information/query to 'sql' log file

  • access: protected
void debug (string $query)
  • string $query: SQL query
dsn_connect (line 122)

Connect to specific database

  • return: database handle
  • access: protected
PDO dsn_connect (array $dsn)
  • array $dsn: DSN for DB connections
dsn_options (line 1025)

Returns driver-specific connection options

  • return: Connection options
  • access: protected
array dsn_options (array $dsn)
  • array $dsn: DSN parameters

Redefined in descendants as:
dsn_string (line 994)

Returns PDO DSN string from DSN array

  • return: DSN string
  • access: protected
string dsn_string (array $dsn)
  • array $dsn: DSN parameters

Redefined in descendants as:
escape (line 644)

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

  • return: Escaped string for use in a query
  • access: public
string escape (string $str)
  • string $str: A string to escape
escapeSimple (line 676)

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

  • return: Escaped string for use in a query
  • see: rcube_db::escape
  • deprecated: Replaced by rcube_db::escape
  • access: public
string escapeSimple (string $str)
  • string $str: A string to escape
fetch_array (line 512)

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

  • return: Array with col values or false on failure
  • access: public
mixed fetch_array ([mixed $result = null])
  • mixed $result: Optional query handle
fetch_assoc (line 499)

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

  • return: Array with col values or false on failure
  • access: public
mixed fetch_assoc ([mixed $result = null])
  • mixed $result: Optional query handle
fromunixtime (line 756)

Return SQL statement to convert from a unix timestamp

  • return: Date string in db-specific format
  • access: public
string fromunixtime (int $timestamp)
  • int $timestamp: Unix timestamp
get_variable (line 306)

Get database runtime variables

  • return: Variable value or default
  • access: public
mixed get_variable (string $varname, [mixed $default = null])
  • string $varname: Variable name
  • mixed $default: Default value if variable is not set

Redefined in descendants as:
ilike (line 769)

Return SQL statement for case insensitive LIKE

  • return: SQL statement to use in query
  • access: public
string ilike (string $column, string $value)
  • string $column: Field name
  • string $value: Search value

Redefined in descendants as:
init (line 110)

Initialization of the object with driver specific code

  • access: protected
void init ()

Redefined in descendants as:
insert_id (line 475)

Get last inserted record ID

  • return: ID or false on failure
  • access: public
mixed insert_id ([string $table = ''])
  • string $table: Table name (to find the incremented sequence)

Redefined in descendants as:
is_connected (line 283)

Connection state checker

  • return: True if in connected state
  • access: public
boolean is_connected ()
is_error (line 269)

Getter for error state

  • return: Error message
  • access: public
string is_error ([mixed $result = null])
  • mixed $result: Optional query result
is_replicated (line 293)

Is database replication configured?

  • return: Returns true if dsnw != dsnr
  • access: public
bool is_replicated ()
limitquery (line 343)

Execute a SQL query with limits

  • return: Query handle or False on error
  • access: public
PDOStatement|bool limitquery (string 0, int 1, int 2, mixed 3)
  • string 0: SQL query to execute
  • int 1: Offset for LIMIT statement
  • int 2: Number of rows for LIMIT statement
  • mixed 3: Values to be inserted in query
list_cols (line 585)

Returns list of columns in database table

  • return: List of table cols
  • access: public
array list_cols (string $table)
  • string $table: Table name

Redefined in descendants as:
list_tables (line 561)

Returns list of tables in a database

  • return: List of all tables of the current database
  • access: public
array list_tables ()

Redefined in descendants as:
now (line 707)

Return SQL function for current time and date

  • return: SQL function to use in query
  • access: public
string now ()

Redefined in descendants as:
num_rows (line 450)

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

  • return: Number of rows or false on failure
  • deprecated: This method shows very poor performance and should be avoided.
  • access: public
mixed num_rows ([mixed $result = null])
  • mixed $result: Optional query handle
query (line 320)

Execute a SQL query

  • return: Query handle identifier
  • access: public
number query (string 0, mixed 1)
  • string 0: SQL query to execute
  • mixed 1: Values to be inserted in query
quote (line 605)

Formats input so it can be safely used in a query

  • return: Quoted/converted string for use in query
  • access: public
string quote (mixed $input, [string $type = null])
  • mixed $input: Value to quote
  • string $type: Type of data (integer, bool, ident)
quoteIdentifier (line 662)

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

  • return: Quoted string for use in query
  • see: rcube_db::quote_identifier
  • deprecated: Replaced by rcube_db::quote_identifier
  • access: public
string quoteIdentifier (string $str)
  • string $str: Value to quote
quote_identifier (line 688)

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

  • return: Quoted string for use in query
  • access: public
string quote_identifier (string $str)
  • string $str: Value to quote
set_charset (line 189)

Driver-specific database character set setting

  • access: protected
void set_charset (string $charset)
  • string $charset: Character set name

Redefined in descendants as:
set_debug (line 245)

Activate/deactivate debug mode

  • access: public
void set_debug ([boolean $dbg = true])
  • boolean $dbg: True if SQL queries should be logged
set_limit (line 543)

Adds LIMIT,OFFSET clauses to the query

  • return: SQL query
  • access: protected
string set_limit (string $query, [int $limit = 0], [int $offset = 0])
  • string $query: SQL query
  • int $limit: Number of rows
  • int $offset: Offset

Redefined in descendants as:
table_name (line 846)

Return correct name for a specific database table

  • return: Translated table name
  • access: public
string table_name (string $table)
  • string $table: Table name
unixtimestamp (line 744)

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

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

  • return: SQL statement to use in query
  • deprecated:
  • access: public
string unixtimestamp (string $field)
  • string $field: Field name

Redefined in descendants as:
_fetch_row (line 525)

Get col values for a result row

  • return: Array with col values or false on failure
  • access: protected
mixed _fetch_row (mixed $result, int $mode)
  • mixed $result: Optional query handle
  • int $mode: Fetch mode identifier
_query (line 363)

Execute a SQL query with limits

  • return: Query handle or False on error
  • access: protected
PDOStatement|bool _query (string $query, int $offset, int $numrows, array $params)
  • string $query: SQL query to execute
  • int $offset: Offset for LIMIT statement
  • int $numrows: Number of rows for LIMIT statement
  • array $params: Values to be inserted in query

Documentation generated on Fri, 03 May 2013 12:44:58 +0200 by phpDocumentor 1.4.4