MySQLAdapter
class MySQLAdapter
Class MySQLAdapter
Properties
| mysqli_result | $last_result | ||
| int | $query_count | ||
| protected int | $debug_query_count | ||
| array | $debug_profile | ||
| string|false | $debug_last_query | ||
| int|false | $debug_last_status | ||
| protected mysqli|null | $link | ||
| protected string | $server | ||
| protected string | $username | ||
| protected string | $password | ||
| protected string | $db | ||
| protected int | $port | ||
| protected int | $charset | ||
| protected int | $connection_retries | ||
| protected bool | $autocommit | ||
| protected bool | $fatal_on_error | ||
| static array | $smartTimestampFields |
Methods
Constructur for Database Wrapper
Disconnect Server in case of object destruction
PHP __sleep -> Disconnect Server in case of object serialization
PHP __wakeup ->Re-Connect Server in case of object unserialize
No description
No description
Can the current user create temporary tables?
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
put your comment there.
Close DB Connection
Collect Profiling Infos from Database if in DEVMODE
No description
Connects to the database
Prints information about the last query and it's result code
Returns the error code for the most recent function call
Returns a string description of the last error
No description
Take a mysqldump backup file
Restore mysql database from a mysqldump backup file
No description
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
Return the MariaDB Server Version if MariaDB is detected
Return Server Version as MYSQL Version This function will try to manipulate mariadb versions to match corresponding mysql version
No description
Returns the "SHOW STATUS" result in an array
Returns the mysqli link object
Returns the number of executed queries since connecting the database server
Server Variables
No description
Display width specification for integer data types was deprecated in MySQL 8.0.17
Does this mysql server support JSON fields?
Returns true if the current mySQL server supports utf8mb4 (Emoji)
Is UUID_TO_BIN and BIN_TO_UUID available?
Inserts the passed values into the given table
Detect if the server is a MariaDB server (used to catch some specialties of MariaDB)
Is Database a Galera Cluster?
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
Prepare Profiling Infos from Database if in DEVMODE
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
Free/Close Result Query (Use after rquery)
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
No description
Execute Query (Return Ressource uses MYSQLI_USE_RESULT)
- no builtin Error Handling (ON PURPOSE)
Check Query to avoid SQL Injections
No description
Set the TimeZone for the current mySQL Connection
No description
No description
Updates the table using the passed values
Details
at line 90
__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
at line 354
void
__destruct()
Disconnect Server in case of object destruction
at line 344
void
__sleep()
PHP __sleep -> Disconnect Server in case of object serialization
at line 363
void
__wakeup()
PHP __wakeup ->Re-Connect Server in case of object unserialize
at line 1627
mixed
auto_query(string $type, string $table, array $values = null, array $params = array(), string $FILE = __FILE__, int $LINE = __LINE__, bool $query_type = false, bool $i18nMode = false)
No description
at line 1827
void
begin_transaction()
No description
at line 199
bool|null
can_create_tmp_tables()
Can the current user create temporary tables?
at line 691
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
at line 703
string
check_query_cb(array $matches)
put your comment there.
..
at line 1306
bool
close()
Close DB Connection
at line 1544
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
at line 1837
bool
commit()
No description
at line 221
null
connect(string $charset = 'utf8')
Connects to the database
at line 1806
void
debug()
Prints information about the last query and it's result code
at line 1295
int
errno()
Returns the error code for the most recent function call
at line 1285
string
error()
Returns a string description of the last error
at line 1436
string
escape_string(mixed $string, bool $auto_format_number = true)
No description
at line 1959
bool
executeMysqlDump(string $filename)
Take a mysqldump backup file
at line 1932
executeMysqlRestore(string $filename)
Restore mysql database from a mysqldump backup file
at line 1473
array
extract_search_term(string $search_term)
No description
at line 1922
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
at line 170
int|null
getMariaDBServerVersion()
Return the MariaDB Server Version if MariaDB is detected
at line 151
int
getMySQLServerVersion()
Return Server Version as MYSQL Version This function will try to manipulate mariadb versions to match corresponding mysql version
at line 1864
string
get_charset()
No description
at line 1599
array
get_database_status()
Returns the "SHOW STATUS" result in an array
at line 1856
mysqli
get_link()
Returns the mysqli link object
at line 372
int
get_query_count()
Returns the number of executed queries since connecting the database server
at line 136
array
get_server_vars()
Server Variables
at line 1358
array|bool
get_table_structure(string $table_name)
No description
at line 1897
bool
hasIntDisplayWidthSupport()
Display width specification for integer data types was deprecated in MySQL 8.0.17
at line 1880
bool
hasJsonSupport()
Does this mysql server support JSON fields?
at line 1872
bool
hasUtf8mb4Support()
Returns true if the current mySQL server supports utf8mb4 (Emoji)
at line 1888
bool
hasUuidBinSupport()
Is UUID_TO_BIN and BIN_TO_UUID available?
at line 1115
bool|mixed
insert(string $table, array $values)
Inserts the passed values into the given table
at line 188
bool|null
isMariaDB()
Detect if the server is a MariaDB server (used to catch some specialties of MariaDB)
at line 179
bool
is_cluster()
Is Database a Galera Cluster?
at line 487
mixed
lpquery($query, $params, string $file = __FILE__, int $line = __LINE__, int $cache_ttl = 0, null $cache_group = null)
Execute PQuery Wrapper for Languages
at line 390
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
at line 979
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.
at line 539
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
at line 1588
prepare_debug_profiling()
Prepare Profiling Infos from Database if in DEVMODE
at line 763
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)
at line 741
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
at line 519
void
rclose()
Free/Close Result Query (Use after rquery)
at line 1909
static string|string[]|null
removeSensitiveData($Query)
Helper to remove unwanted private and sensitive data from an SQL query
at line 1178
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
at line 1848
bool
rollback()
No description
at line 503
bool|mysqli_result
rquery(string $query)
Execute Query (Return Ressource uses MYSQLI_USE_RESULT)
- no builtin Error Handling (ON PURPOSE)
at line 1226
static bool
secure_query(string $query, int $allowed = XF_QUERY_ALLOW_NONE)
Check Query to avoid SQL Injections
at line 1818
bool
set_autocommit(bool $mode)
No description
at line 334
void
set_timezone(string $timezone)
Set the TimeZone for the current mySQL Connection
at line 1325
bool
table_exists(string $table_name)
No description
at line 1344
bool
table_field_exists(string $table, string $field)
No description
at line 1134
bool|mixed
update(string $table, array $values, array $where, int $limit = 1)
Updates the table using the passed values