Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
database.php
Go to the documentation of this file.
1 <?php
21 function execute_delayed_write_query($query, $callback = null, array $params = []) {
22  return _elgg_services()->db->registerDelayedQuery($query, 'write', $callback, $params);
23 }
24 
35 function execute_delayed_read_query($query, $callback = null, array $params = []) {
36  return _elgg_services()->db->registerDelayedQuery($query, 'read', $callback, $params);
37 }
38 
55 function get_data($query, $callback = null, array $params = []) {
56  return _elgg_services()->db->getData($query, $callback, $params);
57 }
58 
72 function get_data_row($query, $callback = null, array $params = []) {
73  return _elgg_services()->db->getDataRow($query, $callback, $params);
74 }
75 
87 function insert_data($query, array $params = []) {
88  return _elgg_services()->db->insertData($query, $params);
89 }
90 
102 function update_data($query, array $params = [], $get_num_rows = false) {
103  return _elgg_services()->db->updateData($query, $get_num_rows, $params);
104 }
105 
116 function delete_data($query, array $params = []) {
117  return _elgg_services()->db->deleteData($query, $params);
118 }
119 
140 function run_sql_script($scriptlocation) {
141  _elgg_services()->db->runSqlScript($scriptlocation);
142 }
143 
154  return _elgg_services()->db->sanitizeString($string);
155 }
156 
167  return _elgg_services()->db->sanitizeString($string);
168 }
169 
180 function sanitize_int($int, $signed = true) {
181  return _elgg_services()->db->sanitizeInt($int, $signed);
182 }
183 
194 function sanitise_int($int, $signed = true) {
195  return sanitize_int($int, $signed);
196 }
197 
206  _elgg_services()->db->enableQueryCache();
207 }
208 
219  _elgg_services()->db->disableQueryCache();
220 }
221 
229  $db_calls = _elgg_services()->db->getQueryCount();
230 
231  // demoted to NOTICE as it corrupts javascript at DEBUG
232  elgg_log("DB Queries for this page: $db_calls", 'INFO');
233 }
234 
251  return _elgg_services()->queryCounter;
252 }
253 
261  _elgg_services()->db->executeDelayedQueries();
262 }
263 
274 function _elgg_db_test($hook, $type, $value) {
275  $value[] = elgg_get_engine_path() . '/tests/ElggDataFunctionsTest.php';
276  return $value;
277 }
278 
284 function _elgg_db_init() {
285  register_shutdown_function('_elgg_db_run_delayed_queries');
286  register_shutdown_function('_elgg_db_log_profiling_data');
287  elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_db_test');
288 }
289 
290 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
291  $events->registerHandler('init', 'system', '_elgg_db_init');
292 };
insert_data($query, array $params=[])
Insert a row into the database.
Definition: database.php:87
_elgg_db_test($hook, $type, $value)
Runs unit tests for the database.
Definition: database.php:274
_elgg_db_log_profiling_data()
Log db profiling information at NOTICE debug level upon shutdown.
Definition: database.php:228
_elgg_db_get_query_counter()
Get a new query counter that will begin counting from 0.
Definition: database.php:250
elgg_disable_query_cache()
Disable the MySQL query cache.
Definition: database.php:218
delete_data($query, array $params=[])
Remove a row from the database.
Definition: database.php:116
$value
Definition: longtext.php:26
_elgg_db_run_delayed_queries()
Execute any delayed queries upon shutdown.
Definition: database.php:260
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:715
sanitize_string($string)
Sanitizes a string for use in a query.
Definition: database.php:153
$string
$params
Definition: login.php:72
get_data_row($query, $callback=null, array $params=[])
Retrieve a single row from the database.
Definition: database.php:72
update_data($query, array $params=[], $get_num_rows=false)
Update a row in the database.
Definition: database.php:102
elgg_enable_query_cache()
Enable the MySQL query cache.
Definition: database.php:205
execute_delayed_write_query($query, $callback=null, array $params=[])
Queue a query for running during shutdown that writes to the database.
Definition: database.php:21
sanitise_string($string)
Alias of sanitize_string.
Definition: database.php:166
_elgg_db_init()
Registers shutdown functions for database profiling and delayed queries.
Definition: database.php:284
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
Definition: database.php:55
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition: elgglib.php:1000
run_sql_script($scriptlocation)
Runs a full database script from disk.
Definition: database.php:140
elgg_get_engine_path()
/path/to/elgg/engine
sanitise_int($int, $signed=true)
Alias of sanitize_int.
Definition: database.php:194
execute_delayed_read_query($query, $callback=null, array $params=[])
Queue a query for running during shutdown that reads from the database.
Definition: database.php:35
sanitize_int($int, $signed=true)
Sanitizes an integer for database use.
Definition: database.php:180
if(!$display_name) $type
Definition: delete.php:27