Elgg  Version 1.9
database.php
Go to the documentation of this file.
1 <?php
19 function execute_delayed_write_query($query, $handler = "") {
20  return _elgg_services()->db->registerDelayedQuery($query, 'write', $handler);
21 }
22 
31 function execute_delayed_read_query($query, $handler = "") {
32  return _elgg_services()->db->registerDelayedQuery($query, 'read', $handler);
33 }
34 
50 function get_data($query, $callback = "") {
51  return _elgg_services()->db->getData($query, $callback);
52 }
53 
66 function get_data_row($query, $callback = "") {
67  return _elgg_services()->db->getDataRow($query, $callback);
68 }
69 
80 function insert_data($query) {
81  return _elgg_services()->db->insertData($query);
82 }
83 
93 function update_data($query) {
94  return _elgg_services()->db->updateData($query);
95 }
96 
106 function delete_data($query) {
107  return _elgg_services()->db->deleteData($query);
108 }
109 
130 function run_sql_script($scriptlocation) {
131  _elgg_services()->db->runSqlScript($scriptlocation);
132 }
133 
141  return _elgg_services()->db->sanitizeString($string);
142 }
143 
151  return sanitize_string($string);
152 }
153 
161 function sanitize_int($int, $signed = true) {
162  return _elgg_services()->db->sanitizeInt($int, $signed);
163 }
164 
173 function sanitise_int($int, $signed = true) {
174  return sanitize_int($int, $signed);
175 }
176 
184  $db_calls = _elgg_services()->db->getQueryCount();
185 
186  // demoted to NOTICE as it corrupts javascript at DEBUG
187  elgg_log("DB Queries for this page: $db_calls", 'INFO');
188 }
189 
206  return _elgg_services()->queryCounter;
207 }
208 
216  _elgg_services()->db->executeDelayedQueries();
217 }
218 
224 function _elgg_db_init() {
225  register_shutdown_function('_elgg_db_run_delayed_queries');
226  register_shutdown_function('_elgg_db_log_profiling_data');
227 }
228 
229 elgg_register_event_handler('init', 'system', '_elgg_db_init');
_elgg_db_log_profiling_data()
Log db profiling information at NOTICE debug level upon shutdown.
Definition: database.php:183
_elgg_db_get_query_counter()
Get a new query counter that will begin counting from 0.
Definition: database.php:205
get_data_row($query, $callback="")
Retrieve a single row from the database.
Definition: database.php:66
_elgg_db_run_delayed_queries()
Execute any delayed queries upon shutdown.
Definition: database.php:215
delete_data($query)
Remove a row from the database.
Definition: database.php:106
update_data($query)
Update a row in the database.
Definition: database.php:93
sanitize_string($string)
Sanitize a string for database use.
Definition: database.php:140
$string
insert_data($query)
Insert a row into the database.
Definition: database.php:80
execute_delayed_read_query($query, $handler="")
Queue a query for running during shutdown that reads from the database.
Definition: database.php:31
execute_delayed_write_query($query, $handler="")
Queue a query for running during shutdown that writes to the database.
Definition: database.php:19
_elgg_services()
Definition: autoloader.php:14
sanitise_string($string)
Wrapper function for alternate English spelling (.
Definition: database.php:150
_elgg_db_init()
Registers shutdown functions for database profiling and delayed queries.
Definition: database.php:224
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
Definition: elgglib.php:669
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition: elgglib.php:1083
run_sql_script($scriptlocation)
Runs a full database script from disk.
Definition: database.php:130
get_data($query, $callback="")
Retrieve rows from the database.
Definition: database.php:50
sanitise_int($int, $signed=true)
Sanitizes an integer for database use.
Definition: database.php:173
$handler
Definition: add.php:10
sanitize_int($int, $signed=true)
Sanitizes an integer for database use.
Definition: database.php:161