DB
class DB extends MySQLAdapter
Database Wrapper (mySQL)
Properties
int | $server_version | from MySQLAdapter | |
mysqli_result | $last_result | from MySQLAdapter | |
int | $query_count | from MySQLAdapter | |
protected int | $debug_query_count | from MySQLAdapter | |
array | $debug_profile | from MySQLAdapter | |
string|false | $debug_last_query | from MySQLAdapter | |
int|false | $debug_last_status | from MySQLAdapter | |
protected | $link | ||
protected | $server | ||
protected | $username | ||
protected | $password | ||
protected | $db | ||
protected int | $port | from MySQLAdapter | |
protected int | $charset | from MySQLAdapter | |
protected | $connection_retries | ||
protected bool | $autocommit | from MySQLAdapter | |
protected bool | $fatal_on_error | from MySQLAdapter | |
static | $smartTimestampFields | from MySQLAdapter |
Methods
Constructur for Database Wrapper
No description
Checks the passed SQL query string for system-wide table placeholder markers and returns the query with the corresponding replacements e.g. ###sys|tablename### will be replaced to use the correct system table prefix
Collect Profiling Infos from Database if in DEVMODE
Restore mysql database from a mysqldump backup file
Helper to Format multi-line SQL statements into a single line for log output NOTE: The resulting query string is for display purposes only and should not be used again as query as also field values may be shortened
Returns the number of executed queries since connecting the database server
Returns true if the current mySQL server supports utf8mb4 (Emoji)
Inserts the passed values into the given table
Execute PQuery Wrapper for Languages
Execute Query Wrapper for Languages
Executes multiple queries in one request -> Preferred way e.g. to mass insert data into database as this is much faster than many single queries If an error occures the execution stops and all remaining queries won't be executed.
Prepared Statement Query
Execute Query (Return Result Array/Count)
Execute Query (Return Result Array/Count) with passing of parameters e.g. use "SELECT * FROM tbl WHERE id = :id" as query and pass the value for "id" as params array ['id'=>2] All passed values will be automatically escaped for security reasons
Helper to remove unwanted private and sensitive data from an SQL query
Pass a query with placeholders and pass values for placeholders as keyed array. The function will replace all placeholder with their respective values from the array and escape them accordingly
Execute Query (Return Ressource uses MYSQLI_USE_RESULT)
- no builtin Error Handling (ON PURPOSE)
Check Query to avoid SQL Injections
Set the TimeZone for the current mySQL Connection
Updates the table using the passed values
Details
in
MySQLAdapter at line 89
__construct(string $server = XF_DB_SERVER, string $username = XF_DB_USER, string $password = XF_DB_PASS, string $db = XF_DB_DATABASE, string $charset = 'utf8', bool $fatal_on_error = true, int $port = 3306)
Constructur for Database Wrapper
Initializes database connection
in
MySQLAdapter at line 294
void
__destruct()
Disconnect Server in case of object destruction
in
MySQLAdapter at line 284
void
__sleep()
PHP __sleep -> Disconnect Server in case of object serialization
in
MySQLAdapter at line 303
void
__wakeup()
PHP __wakeup ->Re-Connect Server in case of object unserialize
in
MySQLAdapter at line 1513
mixed
auto_query(string $type, string $table, array $values = null, array $params = array(), string $FILE = __FILE__, int $LINE = __LINE__, bool $query_type = false)
No description
in
MySQLAdapter at line 1728
void
begin_transaction()
No description
in
MySQLAdapter at line 157
bool|null
can_create_tmp_tables()
Can the current user create temporary tables?
in
MySQLAdapter at line 631
string
check_query(string $query)
Checks the passed SQL query string for system-wide table placeholder markers and returns the query with the corresponding replacements e.g. ###sys|tablename### will be replaced to use the correct system table prefix
in
MySQLAdapter at line 643
string
check_query_cb(array $matches)
put your comment there.
..
in
MySQLAdapter at line 1230
bool
close()
Close DB Connection
in
MySQLAdapter at line 1430
collect_debug_profiling(mixed $force = false, string $query = null, bool|string $file = false, bool|string $line = false, bool|mysqli_result $result = false, $cacheHit = false)
Collect Profiling Infos from Database if in DEVMODE
in
MySQLAdapter at line 1738
bool
commit()
No description
in
MySQLAdapter at line 179
null
connect(string $charset = 'utf8')
Connects to the database
in
MySQLAdapter at line 1707
void
debug()
Prints information about the last query and it's result code
in
MySQLAdapter at line 1219
int
errno()
Returns the error code for the most recent function call
in
MySQLAdapter at line 1209
string
error()
Returns a string description of the last error
in
MySQLAdapter at line 1323
string
escape_string($string, bool $auto_format_number = true)
No description
in
MySQLAdapter at line 1834
void
executeMysqlDump(string $filename)
Take a mysqldump backup file
in
MySQLAdapter at line 1808
executeMysqlRestore(string $filename)
Restore mysql database from a mysqldump backup file
in
MySQLAdapter at line 1360
array
extract_search_term(string $search_term)
No description
in
MySQLAdapter at line 1798
static string|string[]|null
formatQueryForSinglelineOutput($Query)
Helper to Format multi-line SQL statements into a single line for log output NOTE: The resulting query string is for display purposes only and should not be used again as query as also field values may be shortened
in
MySQLAdapter at line 1765
string
get_charset()
No description
in
MySQLAdapter at line 1485
array
get_database_status()
Returns the "SHOW STATUS" result in an array
in
MySQLAdapter at line 1757
mysqli
get_link()
Returns the mysqli link object
in
MySQLAdapter at line 312
int
get_query_count()
Returns the number of executed queries since connecting the database server
in
MySQLAdapter at line 135
array
get_server_vars()
Server Variables
in
MySQLAdapter at line 1282
array|bool
get_table_structure(string $table_name)
No description
in
MySQLAdapter at line 1773
bool
has_utf8mb4_support()
Returns true if the current mySQL server supports utf8mb4 (Emoji)
in
MySQLAdapter at line 1045
bool|mixed
insert(string $table, array $values)
Inserts the passed values into the given table
in
MySQLAdapter at line 148
bool
is_cluster()
Is Database a Galera Cluster?
in
MySQLAdapter at line 427
mixed
lpquery($query, $params, string $file = __FILE__, int $line = __LINE__, int $cache_ttl = 0, null $cache_group = null)
Execute PQuery Wrapper for Languages
in
MySQLAdapter at line 330
mixed|null
lquery($query, string $result_type = "mysql_fetch_array", string $file = __FILE__, int $line = __LINE__, bool $cache_ttl = false, bool $cache_group = false, bool $query_type = false)
Execute Query Wrapper for Languages
in
MySQLAdapter at line 909
true|array
multiQuery(array $queries, bool $returnResults = false, bool $useTransaction = true)
Executes multiple queries in one request -> Preferred way e.g. to mass insert data into database as this is much faster than many single queries If an error occures the execution stops and all remaining queries won't be executed.
in
MySQLAdapter at line 479
mixed
pquery(string $query, array $params = array(), string $file = __FILE__, int|string $line = __LINE__, int $cache_ttl = 0, null $cache_group = null)
Prepared Statement Query
in
MySQLAdapter at line 1474
prepare_debug_profiling()
Prepare Profiling Infos from Database if in DEVMODE
in
MySQLAdapter at line 703
false|int|array|mysqli_result
query(string $query, string $result_type = "mysql_fetch_array", string $file = __FILE__, int $line = __LINE__, int $cache_ttl = null, string $cache_group = null, string $query_type = null)
Execute Query (Return Result Array/Count)
in
MySQLAdapter at line 681
mixed
query_with_params(string $query, array $params, string $result_type = "mysql_fetch_array", string $file = __FILE__, int $line = __LINE__, int $cache_ttl = null, string $cache_group = null, string $query_type = null)
Execute Query (Return Result Array/Count) with passing of parameters e.g. use "SELECT * FROM tbl WHERE id = :id" as query and pass the value for "id" as params array ['id'=>2] All passed values will be automatically escaped for security reasons
in
MySQLAdapter at line 459
void
rclose()
Free/Close Result Query (Use after rquery)
in
MySQLAdapter at line 1785
static string|string[]|null
removeSensitiveData($Query)
Helper to remove unwanted private and sensitive data from an SQL query
in
MySQLAdapter at line 1108
null|string|string[]
replace_query_placeholder(string $query, array $vars, string $format = 'value', array $value_list = [])
Pass a query with placeholders and pass values for placeholders as keyed array. The function will replace all placeholder with their respective values from the array and escape them accordingly
in
MySQLAdapter at line 1749
bool
rollback()
No description
in
MySQLAdapter at line 443
bool|mysqli_result
rquery(string $query)
Execute Query (Return Ressource uses MYSQLI_USE_RESULT)
- no builtin Error Handling (ON PURPOSE)
in
MySQLAdapter at line 1150
static bool
secure_query(string $query, int $allowed = XF_QUERY_ALLOW_NONE)
Check Query to avoid SQL Injections
in
MySQLAdapter at line 1719
bool
set_autocommit(bool $mode)
No description
in
MySQLAdapter at line 274
void
set_timezone(string $timezone)
Set the TimeZone for the current mySQL Connection
in
MySQLAdapter at line 1249
bool
table_exists(string $table_name)
No description
in
MySQLAdapter at line 1268
bool
table_field_exists(string $table, string $field)
No description
in
MySQLAdapter at line 1064
bool|mixed
update(string $table, array $values, array $where, int $limit = 1)
Updates the table using the passed values