phpBB API Documentation
Class

dbal_mysql

class dbal_mysql extends dbal

MySQL4 Database Abstraction Layer Compatible with: MySQL 3.23+ MySQL 4.0+ MySQL 4.1+ MySQL 5.0+

Properties

$db_connect_id
$query_result
$return_on_error
$transaction
$sql_time
$num_queries
$open_queries
$curtime
$query_hold
$html_hold
$sql_report
$persistency
$user
$server
$dbname
$sql_error_triggered
$sql_error_sql
$sql_error_returned
$transactions
$multi_insert
$sql_layer Current sql layer
$any_char Wildcards for matching any (%) or exactly one (_) character within LIKE expressions
$one_char
$sql_server_version Exact version of the DBAL, directly queried
$connect_error

Methods

dbal()

Constructor

from dbal
sql_return_on_error($fail = false)

return on error or display error message

from dbal
sql_num_queries($cached = false)

Return number of sql queries and cached sql queries used

from dbal
sql_add_num_queries($cached = false)

Add to query count

from dbal
sql_close()

DBAL garbage collection, close sql connection

from dbal
sql_query_limit($query, $total, $offset, $cache_ttl)

Build LIMIT query Doing some validation here.

from dbal
sql_fetchrowset($query_id = false)

Fetch all rows

from dbal
sql_rowseek($rownum, $query_id)

Seek to given row number rownum is zero-based

sql_fetchfield($field, $rownum = false, $query_id = false)

Fetch field if rownum is false, the current row is used, else it is pointing to the row (zero-based)

from dbal
string sql_like_expression(string $expression)

Correctly adjust LIKE expression for special characters Some DBMS are handling them in a different way

from dbal
bool sql_buffer_nested_transactions()

Returns whether results of a query need to be buffered to run a transaction while iterating over them.

from dbal
sql_transaction($status = 'begin')

SQL Transaction

from dbal
sql_build_array($query, $assoc_ary = false)

Build sql statement from array for insert/update/select statements

from dbal
sql_in_set($field, $array, $negate = false, $allow_empty_set = false)

Build IN or NOT IN sql comparison string, uses <> or = on single element arrays to improve comparison speed

from dbal
sql_bit_and(string $column_name, int $bit, string $compare = '')

Run binary AND operator on DB column.

from dbal
sql_bit_or(string $column_name, int $bit, string $compare = '')

Run binary OR operator on DB column.

from dbal
string sql_lower_text(string $column_name)

Run LOWER() on DB column of type text (i.e.

from dbal
bool sql_multi_insert(string $table, array $sql_ary)

Run more than one insert statement.

from dbal
_sql_validate_value($var)

Function for validating values

from dbal
sql_build_query($query, $array)

Build sql statement from array for select and select distinct statements

from dbal
sql_error($sql = '')

display sql error page

from dbal
sql_report($mode, $query = '')

Explain queries

from dbal
string get_estimated_row_count(string $table_name)

Gets the estimated number of rows in a specified table.

string get_row_count(string $table_name)

Gets the exact number of rows in a specified table.

sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)

Connect to server

string sql_server_info(bool $raw = false, bool $use_cache = true)

Version information about used database

_sql_transaction($status = 'begin')

SQL Transaction

sql_query($query = '', $cache_ttl)

Base query method

_sql_query_limit($query, $total, $offset, $cache_ttl)

Build LIMIT query

sql_affectedrows()

Return number of affected rows

sql_fetchrow($query_id = false)

Fetch current row

sql_nextid()

Get last inserted id after insert statement

sql_freeresult($query_id = false)

Free sql result

sql_escape($msg)

Escape string used in sql query

array get_table_status(string $table_name)

Gets some information about the specified table.

_sql_like_expression($expression)

Build LIKE expression

_sql_custom_build($stage, $data)

Build db-specific query data

_sql_error()

return sql error array

_sql_close()

Close sql connection

_sql_report($mode, $query = '')

Build db-specific report

Details

in dbal at line 76
public dbal()

Constructor

in dbal at line 96
public sql_return_on_error($fail = false)

return on error or display error message

Parameters

$fail

in dbal at line 107
public sql_num_queries($cached = false)

Return number of sql queries and cached sql queries used

Parameters

$cached

in dbal at line 115
public sql_add_num_queries($cached = false)

Add to query count

Parameters

$cached

in dbal at line 125
public sql_close()

DBAL garbage collection, close sql connection

in dbal at line 159
public sql_query_limit($query, $total, $offset, $cache_ttl)

Build LIMIT query Doing some validation here.

Parameters

$query
$total
$offset
$cache_ttl

in dbal at line 176
public sql_fetchrowset($query_id = false)

Fetch all rows

Parameters

$query_id

at line 275
public sql_rowseek($rownum, $query_id)

Seek to given row number rownum is zero-based

Parameters

$rownum
$query_id

in dbal at line 244
public sql_fetchfield($field, $rownum = false, $query_id = false)

Fetch field if rownum is false, the current row is used, else it is pointing to the row (zero-based)

Parameters

$field
$rownum
$query_id

in dbal at line 279
public string sql_like_expression(string $expression)

Correctly adjust LIKE expression for special characters Some DBMS are handling them in a different way

Parameters

string $expression The expression to use. Every wildcard is escaped, except $this->anychar and $this->onechar

Return Value

string LIKE expression including the keyword!

in dbal at line 292
public bool sql_buffer_nested_transactions()

Returns whether results of a query need to be buffered to run a transaction while iterating over them.

Return Value

bool Whether buffering is required.

in dbal at line 301
public sql_transaction($status = 'begin')

SQL Transaction

Parameters

$status

in dbal at line 370
public sql_build_array($query, $assoc_ary = false)

Build sql statement from array for insert/update/select statements

Idea for this from Ikonboard Possible query values: INSERT, INSERT_SELECT, UPDATE, SELECT

Parameters

$query
$assoc_ary

in dbal at line 425
public sql_in_set($field, $array, $negate = false, $allow_empty_set = false)

Build IN or NOT IN sql comparison string, uses <> or = on single element arrays to improve comparison speed

Parameters

$field
$array
$negate
$allow_empty_set

in dbal at line 475
public sql_bit_and(string $column_name, int $bit, string $compare = '')

Run binary AND operator on DB column.

Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}"

Parameters

string $column_name The column name to use
int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29
string $compare Any custom SQL code after the check (for example "= 0")

in dbal at line 493
public sql_bit_or(string $column_name, int $bit, string $compare = '')

Run binary OR operator on DB column.

Results in sql statement: "{$column_name} | (1 << {$bit}) {$compare}"

Parameters

string $column_name The column name to use
int $bit The value to use for the OR operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29
string $compare Any custom SQL code after the check (for example "= 0")

in dbal at line 510
public string sql_lower_text(string $column_name)

Run LOWER() on DB column of type text (i.e.

neither varchar nor char).

Parameters

string $column_name The column name to use

Return Value

string A SQL statement like "LOWER($column_name)"

in dbal at line 524
public bool sql_multi_insert(string $table, array $sql_ary)

Run more than one insert statement.

Parameters

string $table table name to run the statements on
array $sql_ary multi-dimensional array holding the statement data.

Return Value

bool false if no statements were executed.

in dbal at line 577
public _sql_validate_value($var)

Function for validating values

Parameters

$var

in dbal at line 598
public sql_build_query($query, $array)

Build sql statement from array for select and select distinct statements

Possible query values: SELECT, SELECT_DISTINCT

Parameters

$query
$array

in dbal at line 701
public sql_error($sql = '')

display sql error page

Parameters

$sql

in dbal at line 771
public sql_report($mode, $query = '')

Explain queries

Parameters

$mode
$query

at line 349
public string get_estimated_row_count(string $table_name)

Gets the estimated number of rows in a specified table.

Parameters

string $table_name Table name

Return Value

string Number of rows in $table_name. Prefixed with ~ if estimated (otherwise exact).

at line 377
public string get_row_count(string $table_name)

Gets the exact number of rows in a specified table.

Parameters

string $table_name Table name

Return Value

string Exact number of rows in $table_name.

at line 39
public sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)

Connect to server

Parameters

$sqlserver
$sqluser
$sqlpassword
$database
$port
$persistency
$new_link

at line 120
public string sql_server_info(bool $raw = false, bool $use_cache = true)

Version information about used database

Parameters

bool $raw if true, only return the fetched sqlserverversion
bool $use_cache If true, it is safe to retrieve the value from the cache

Return Value

string sql server version

at line 145
public _sql_transaction($status = 'begin')

SQL Transaction

Parameters

$status

at line 174
public sql_query($query = '', $cache_ttl)

Base query method

Parameters

$query
$cache_ttl

at line 227
public _sql_query_limit($query, $total, $offset, $cache_ttl)

Build LIMIT query

Parameters

$query
$total
$offset
$cache_ttl

at line 246
public sql_affectedrows()

Return number of affected rows

at line 254
public sql_fetchrow($query_id = false)

Fetch current row

Parameters

$query_id

at line 295
public sql_nextid()

Get last inserted id after insert statement

at line 303
public sql_freeresult($query_id = false)

Free sql result

Parameters

$query_id

at line 329
public sql_escape($msg)

Escape string used in sql query

Parameters

$msg

at line 398
public array get_table_status(string $table_name)

Gets some information about the specified table.

Parameters

string $table_name Table name

Return Value

array

at line 413
public _sql_like_expression($expression)

Build LIKE expression

Parameters

$expression

at line 422
public _sql_custom_build($stage, $data)

Build db-specific query data

Parameters

$stage
$data

at line 438
public _sql_error()

return sql error array

at line 469
public _sql_close()

Close sql connection

at line 478
public _sql_report($mode, $query = '')

Build db-specific report

Parameters

$mode
$query