Elgg
Version 2.3
|
Go to the source code of this file.
Namespaces | |
Elgg\Core | |
Activate a plugin or plugins. | |
Functions | |
execute_delayed_write_query ($query, $callback=null, array $params=[]) | |
Queue a query for running during shutdown that writes to the database. More... | |
execute_delayed_read_query ($query, $callback=null, array $params=[]) | |
Queue a query for running during shutdown that reads from the database. More... | |
get_data ($query, $callback=null, array $params=[]) | |
Retrieve rows from the database. More... | |
get_data_row ($query, $callback=null, array $params=[]) | |
Retrieve a single row from the database. More... | |
insert_data ($query, array $params=[]) | |
Insert a row into the database. More... | |
update_data ($query, array $params=[], $get_num_rows=false) | |
Update a row in the database. More... | |
delete_data ($query, array $params=[]) | |
Remove a row from the database. More... | |
run_sql_script ($scriptlocation) | |
Runs a full database script from disk. More... | |
sanitize_string ($string) | |
Sanitizes a string for use in a query. More... | |
sanitise_string ($string) | |
Alias of sanitize_string. More... | |
sanitize_int ($int, $signed=true) | |
Sanitizes an integer for database use. More... | |
sanitise_int ($int, $signed=true) | |
Alias of sanitize_int. More... | |
elgg_enable_query_cache () | |
Enable the MySQL query cache. More... | |
elgg_disable_query_cache () | |
Disable the MySQL query cache. More... | |
_elgg_db_log_profiling_data () | |
Log db profiling information at NOTICE debug level upon shutdown. More... | |
_elgg_db_get_query_counter () | |
Get a new query counter that will begin counting from 0. More... | |
_elgg_db_run_delayed_queries () | |
Execute any delayed queries upon shutdown. More... | |
_elgg_db_test ($hook, $type, $value) | |
Runs unit tests for the database. More... | |
_elgg_db_init () | |
Registers shutdown functions for database profiling and delayed queries. More... | |
Variables | |
return | function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks) |
_elgg_db_get_query_counter | ( | ) |
Get a new query counter that will begin counting from 0.
For profiling isolated sections of code.
$counter = _elgg_db_get_query_counter();
... code to profile
$counter->setDeltaHeader();
Definition at line 250 of file database.php.
_elgg_db_init | ( | ) |
Registers shutdown functions for database profiling and delayed queries.
private
Definition at line 284 of file database.php.
_elgg_db_log_profiling_data | ( | ) |
Log db profiling information at NOTICE debug level upon shutdown.
Definition at line 228 of file database.php.
_elgg_db_run_delayed_queries | ( | ) |
Execute any delayed queries upon shutdown.
Definition at line 260 of file database.php.
_elgg_db_test | ( | $hook, | |
$type, | |||
$value | |||
) |
Runs unit tests for the database.
string | $hook | unit_test |
string | $type | system |
array | $value | Array of tests |
Definition at line 274 of file database.php.
delete_data | ( | $query, | |
array | $params = [] |
||
) |
Remove a row from the database.
string | $query | The SQL query to run |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Definition at line 116 of file database.php.
elgg_disable_query_cache | ( | ) |
Disable the MySQL query cache.
Definition at line 218 of file database.php.
elgg_enable_query_cache | ( | ) |
execute_delayed_read_query | ( | $query, | |
$callback = null , |
|||
array | $params = [] |
||
) |
Queue a query for running during shutdown that reads from the database.
string | $query | The query to execute |
callable | $callback | The optional callback for processing. The callback will receive a object |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Definition at line 35 of file database.php.
execute_delayed_write_query | ( | $query, | |
$callback = null , |
|||
array | $params = [] |
||
) |
Queue a query for running during shutdown that writes to the database.
string | $query | The query to execute |
callable | $callback | The optional callback for processing. The callback will receive a object |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Definition at line 21 of file database.php.
get_data | ( | $query, | |
$callback = null , |
|||
array | $params = [] |
||
) |
Retrieve rows from the database.
Queries are executed with Elgg\Database::getResultsandresultsareretrievedwith@link\PDO::fetchObject().Ifacallbackfunction$callbackisdefined,eachrowwillbepassedasthesingleargumentto$callback.Ifnocallbackfunctionisdefined,theentireresultsetisreturnedasanarray.@paramstring$queryThequerybeingpassed.@paramcallable$callbackOptionally,thenameofafunctiontocallbacktooneachrow@paramarray$paramsQueryparams.E.g.[1,'steve']or[':id'=>1,':name'=>'steve']@returnarrayAnarrayofdatabaseresultobjectsorcallbackfunctionresults.Ifthequeryreturnednothing,anemptyarray.
Definition at line 55 of file database.php.
get_data_row | ( | $query, | |
$callback = null , |
|||
array | $params = [] |
||
) |
Retrieve a single row from the database.
Similar to get_data() but returns only the first row matched. If a callback function $callback is specified, the row will be passed as the only argument to $callback.
string | $query | The query to execute. |
callable | $callback | A callback function to apply to the row |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Definition at line 72 of file database.php.
insert_data | ( | $query, | |
array | $params = [] |
||
) |
Insert a row into the database.
string | $query | The query to execute. |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Definition at line 87 of file database.php.
run_sql_script | ( | $scriptlocation | ) |
Runs a full database script from disk.
The file specified should be a standard SQL file as created by mysqldump or similar. Statements must be terminated with ; and a newline character (
or
) with only one statement per line.
The special string 'prefix_' is replaced with the database prefix as defined in ->dbprefix.
string | $scriptlocation | The full path to the script |
DatabaseException |
Definition at line 140 of file database.php.
sanitise_int | ( | $int, | |
$signed = true |
|||
) |
Alias of sanitize_int.
int | $int | Value to be sanitized |
bool | $signed | Whether negative values should be allowed (true) |
Definition at line 194 of file database.php.
sanitise_string | ( | $string | ) |
Alias of sanitize_string.
string | $string | The string to sanitize |
Definition at line 166 of file database.php.
sanitize_int | ( | $int, | |
$signed = true |
|||
) |
Sanitizes an integer for database use.
int | $int | Value to be sanitized |
bool | $signed | Whether negative values should be allowed (true) |
Definition at line 180 of file database.php.
sanitize_string | ( | $string | ) |
Sanitizes a string for use in a query.
string | $string | The string to sanitize |
Definition at line 153 of file database.php.
update_data | ( | $query, | |
array | $params = [] , |
||
$get_num_rows = false |
|||
) |
Update a row in the database.
string | $query | The query to run. |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
bool | $get_num_rows | Return the number of rows affected (default: false). |
Definition at line 102 of file database.php.
return function(\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks) |
Definition at line 290 of file database.php.