Class rcube_mdb2

Description

Database independent query interface

This is a wrapper for the PEAR::MDB2 class

Located in /rcube_mdb2.php (line 39)


	
			
Variable Summary
 mixed $db_dsnr
 mixed $db_dsnw
 mixed $db_error
 mixed $db_handle
 mixed $db_mode
Method Summary
 rcube_mdb2 __construct (string $db_dsnw, [string $db_dsnr = ''], [ $pconn = false])
 mixed affected_rows ([number $res_id = null])
 string array2list (array $arr, [string $type = null])
 string concat ()
 void db_connect (string $mode)
 void debug_handler ( &$db,  $scope,  $message, [ $context = array()])
 mixed decode (mixed $input)
 mixed encode (mixed $input)
 string escapeSimple (string $str)
 mixed fetch_array ([number $res_id = null])
 mixed fetch_assoc ([number $res_id = null])
 string fromunixtime (string $timestamp)
 string ilike (string $column, string $value)
 mixed insert_id ([string $table = ''])
 void is_connected (boolean 0)
 void is_error (boolean 0)
 void is_replicated ()
 number limitquery (string 0, number 1, number 2, mixed 3)
 array list_cols (string $table)
 array list_tables ()
 string now ()
 mixed num_rows ([number $res_id = 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_debug ([boolean $dbg = true])
 string unixtimestamp (string $field)
Variables
mixed $db_connected = false (line 43)
  • access: public
mixed $db_dsnr (line 42)
  • access: public
mixed $db_dsnw (line 41)
  • access: public
mixed $db_error = false (line 46)
  • access: public
mixed $db_error_msg = '' (line 47)
  • access: public
mixed $db_handle = 0 (line 45)
  • access: public
mixed $db_mode = '' (line 44)
  • access: public
Methods
Constructor __construct (line 62)

Object constructor

rcube_mdb2 __construct (string $db_dsnw, [string $db_dsnr = ''], [ $pconn = false])
  • string $db_dsnw: DSN for read/write operations
  • string $db_dsnr: Optional DSN for read only operations
  • $pconn
affected_rows (line 339)

Get number of affected rows for the last query

  • return: Number of rows or false on failure
  • access: public
mixed affected_rows ([number $res_id = null])
  • number $res_id: Optional query handle identifier
array2list (line 559)

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
concat (line 635)

Abstract SQL statement for value concatenation

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

Connect to appropiate database depending on the operation

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

Debug handler for the MDB2

void debug_handler ( &$db,  $scope,  $message, [ $context = array()])
  • &$db
  • $scope
  • $message
  • $context
decode (line 691)

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

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

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
escapeSimple (line 523)

Escapes a string

  • return: The escaped string
  • since: 0.1.1
  • access: public
string escapeSimple (string $str)
  • string $str: The string to be escaped
fetch_array (line 399)

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 ([number $res_id = null])
  • number $res_id: Optional query handle identifier
fetch_assoc (line 384)

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 ([number $res_id = null])
  • number $res_id: Optional query handle identifier
fromunixtime (line 604)

Return SQL statement to convert from a unix timestamp

  • return: SQL statement to use in query
  • access: public
string fromunixtime (string $timestamp)
  • string $timestamp: Field name
ilike (line 618)

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
insert_id (line 356)

Get last inserted record ID For Postgres databases, a sequence name is required

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

Connection state checker

  • access: public
void is_connected (boolean 0)
  • boolean 0: True if in connected state
is_error (line 189)

Getter for error state

  • access: public
void is_error (boolean 0)
  • boolean 0: True on error
is_replicated (line 211)

Is database replication configured?

This returns true if dsnw != dsnr

void is_replicated ()
limitquery (line 248)

Execute a SQL query with limits

  • return: Query handle identifier
  • access: public
number limitquery (string 0, number 1, number 2, mixed 3)
  • string 0: SQL query to execute
  • number 1: Offset for LIMIT statement
  • number 2: Number of rows for LIMIT statement
  • mixed 3: Values to be inserted in query
list_cols (line 451)

Wrapper for SHOW COLUMNS command

  • return: List of table cols
array list_cols (string $table)
  • string $table: Table name
list_tables (line 430)

Wrapper for the SHOW TABLES command

  • return: List of all tables of the current database
  • since: 0.4-beta
  • access: public
array list_tables ()
now (line 538)

Return SQL function for current time and date

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

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
  • access: public
mixed num_rows ([number $res_id = null])
  • number $res_id: Optional query handle identifier
query (line 225)

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 470)

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
quoteIdentifier (line 493)

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

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

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_debug (line 173)

Activate/deactivate debug mode

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

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:
string unixtimestamp (string $field)
  • string $field: Field name

Documentation generated on Wed, 23 May 2012 16:40:51 +0200 by phpDocumentor 1.4.4