phpBB API Documentation
Class

phpbb\db\driver\mssql_base

abstract class mssql_base extends driver

MSSQL Database Base Abstraction Layer

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

Methods

__construct()

Constructor

from driver
string get_sql_layer()

Gets the name of the sql layer.

from driver
string get_db_name()

Gets the name of the database.

from driver
string get_any_char()

Wildcards for matching any (%) character within LIKE expressions

from driver
string get_one_char()

Wildcards for matching exactly one (_) character within LIKE expressions

from driver
mixed get_db_connect_id()

Gets the connect ID.

from driver
bool get_sql_error_triggered()

Indicates if an error was triggered.

from driver
string get_sql_error_sql()

Gets the last faulty query

from driver
bool get_transaction()

Indicates if we are in a transaction.

from driver
int get_sql_time()

Gets the time spent into the queries

from driver
array get_sql_error_returned()

Gets the returned error.

from driver
bool get_multi_insert()

Indicates if multiple insertion can be used

from driver
set_multi_insert(bool $multi_insert)

Set if multiple insertion can be used

from driver
null sql_return_on_error(bool $fail = false)

Return on error or display error message

from driver
sql_num_queries($cached = false)

Return number of sql queries and cached sql queries used

from driver
null sql_add_num_queries(bool $cached = false)

Add to query count

from driver
sql_close()

DBAL garbage collection, close SQL connection

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

Build LIMIT query

from driver
sql_fetchrowset($query_id = false)

Fetch all rows

from driver
sql_rowseek($rownum, $query_id)

Seek to given row number

from driver
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 driver
string sql_like_expression($expression)

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

from driver
string sql_not_like_expression($expression)

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

from driver
sql_case($condition, $action_true, $action_false = false)

Build a case expression

from driver
sql_concatenate($expr1, $expr2)

Build a concatenated expression

bool sql_buffer_nested_transactions()

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

from driver
sql_transaction($status = 'begin')

SQL Transaction

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

Build sql statement from an array

from driver
string 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 driver
string sql_bit_and(string $column_name, int $bit, string $compare = '')

Run binary AND operator on DB column.

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

Run binary OR operator on DB column.

from driver
string cast_expr_to_bigint(string $expression)

Returns SQL string to cast a string expression to an int.

from driver
string cast_expr_to_string($expression)

Returns SQL string to cast an integer expression to a string.

from driver
string sql_lower_text(string $column_name)

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

bool sql_multi_insert(string $table, array $sql_ary)

Run more than one insert statement.

from driver
_sql_validate_value($var)

Function for validating values

from driver
sql_build_query($query, $array)

Build sql statement from array for select and select distinct statements

from driver
mixed sql_error(string $sql = '')

Display sql error page

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

Explain queries

from driver
string get_estimated_row_count(string $table_name)

Gets the estimated number of rows in a specified table.

from driver
string get_row_count(string $table_name)

Gets the exact number of rows in a specified table.

from driver
sql_escape($msg)

Escape string used in sql query

_sql_like_expression($expression)

Build LIKE expression

_sql_not_like_expression($expression)

Build NOT LIKE expression

_sql_custom_build($stage, $data)

Build db-specific query data

Details

in driver at line 72
public __construct()

Constructor

in driver at line 92
public string get_sql_layer()

Gets the name of the sql layer.

Return Value

string

in driver at line 100
public string get_db_name()

Gets the name of the database.

Return Value

string

in driver at line 108
public string get_any_char()

Wildcards for matching any (%) character within LIKE expressions

Return Value

string

in driver at line 116
public string get_one_char()

Wildcards for matching exactly one (_) character within LIKE expressions

Return Value

string

in driver at line 124
public mixed get_db_connect_id()

Gets the connect ID.

Return Value

mixed

in driver at line 132
public bool get_sql_error_triggered()

Indicates if an error was triggered.

Return Value

bool

in driver at line 140
public string get_sql_error_sql()

Gets the last faulty query

Return Value

string

in driver at line 148
public bool get_transaction()

Indicates if we are in a transaction.

Return Value

bool

in driver at line 156
public int get_sql_time()

Gets the time spent into the queries

Return Value

int

in driver at line 164
public array get_sql_error_returned()

Gets the returned error.

Return Value

array

in driver at line 172
public bool get_multi_insert()

Indicates if multiple insertion can be used

Return Value

bool

in driver at line 180
public set_multi_insert(bool $multi_insert)

Set if multiple insertion can be used

Parameters

bool $multi_insert

in driver at line 188
public null sql_return_on_error(bool $fail = false)

Return on error or display error message

Parameters

bool $fail Should we return on errors, or stop

Return Value

null

in driver at line 199
public sql_num_queries($cached = false)

Return number of sql queries and cached sql queries used

Parameters

$cached

in driver at line 207
public null sql_add_num_queries(bool $cached = false)

Add to query count

Parameters

bool $cached Is this query cached?

Return Value

null

in driver at line 217
public sql_close()

DBAL garbage collection, close SQL connection

in driver at line 250
public sql_query_limit($query, $total, $offset, $cache_ttl)

Build LIMIT query

Parameters

$query
$total
$offset
$cache_ttl

in driver at line 267
public sql_fetchrowset($query_id = false)

Fetch all rows

Parameters

$query_id

in driver at line 291
public sql_rowseek($rownum, $query_id)

Seek to given row number

Parameters

$rownum
$query_id

in driver at line 333
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 driver at line 364
public string sql_like_expression($expression)

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

Parameters

$expression

Return Value

string A SQL statement like: "LIKE 'bertie_%'"

in driver at line 375
public string sql_not_like_expression($expression)

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

Parameters

$expression

Return Value

string A SQL statement like: "NOT LIKE 'bertie_%'"

in driver at line 386
public sql_case($condition, $action_true, $action_false = false)

Build a case expression

Note: The two statements actiontrue and actionfalse must have the same data type (int, vchar, ...) in the database!

Parameters

$condition
$action_true
$action_false

at line 24
public sql_concatenate($expr1, $expr2)

Build a concatenated expression

Parameters

$expr1
$expr2

in driver at line 406
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 driver at line 414
public sql_transaction($status = 'begin')

SQL Transaction

Parameters

$status

in driver at line 481
public sql_build_array($query, $assoc_ary = false)

Build sql statement from an array

Parameters

$query
$assoc_ary

in driver at line 529
public string 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

Return Value

string A SQL statement like: "IN (1, 2, 3, 4)" or "= 1"

in driver at line 574
public string 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")

Return Value

string A SQL statement like: "{$column} & (1 << {$bit}) {$compare}"

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

Run binary OR operator on DB column.

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 (e.g. "= 0")

Return Value

string A SQL statement like "$column | (1 << $bit) {$compare}"

in driver at line 600
public string cast_expr_to_bigint(string $expression)

Returns SQL string to cast a string expression to an int.

Parameters

string $expression An expression evaluating to string

Return Value

string Expression returning an int

in driver at line 608
public string cast_expr_to_string($expression)

Returns SQL string to cast an integer expression to a string.

Parameters

$expression

Return Value

string Expression returning a string

at line 40
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 driver at line 624
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 driver at line 677
public _sql_validate_value($var)

Function for validating values

Parameters

$var

in driver at line 696
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 driver at line 799
public mixed sql_error(string $sql = '')

Display sql error page

Parameters

string $sql The SQL query causing the error

Return Value

mixed Returns the full error message, if $this->returnonerror is set, null otherwise

in driver at line 869
public sql_report($mode, $query = '')

Explain queries

Parameters

$mode
$query

in driver at line 1059
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).

in driver at line 1067
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 32
public sql_escape($msg)

Escape string used in sql query

Parameters

$msg

at line 49
public _sql_like_expression($expression)

Build LIKE expression

Parameters

$expression

at line 58
public _sql_not_like_expression($expression)

Build NOT LIKE expression

Parameters

$expression

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

Build db-specific query data

Parameters

$stage
$data