Elgg  Version 2.3
Database.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Application;
3 
5 use Elgg\Database as ElggDb;
6 use Elgg\Timer;
7 use Elgg\Logger;
8 
22 class Database extends ElggDb {
23 
29  private $db;
30 
37  public function __construct(ElggDb $db) {
38  $this->db = $db;
39  }
40 
44  public function getData($query, $callback = '', array $params = []) {
45  return $this->db->getData($query, $callback, $params);
46  }
47 
51  public function getDataRow($query, $callback = '', array $params = []) {
52  return $this->db->getDataRow($query, $callback, $params);
53  }
54 
58  public function insertData($query, array $params = []) {
59  return $this->db->insertData($query, $params);
60  }
61 
65  public function updateData($query, $getNumRows = false, array $params = []) {
66  return $this->db->updateData($query, $getNumRows, $params);
67  }
68 
72  public function deleteData($query, array $params = []) {
73  return $this->db->deleteData($query, $params);
74  }
75 
80  public function getTablePrefix() {
81  if (function_exists('elgg_deprecated_notice')) {
82  elgg_deprecated_notice(__METHOD__ . ' is deprecated. Read the "prefix" property', '2.3');
83  }
84  return $this->db->prefix;
85  }
86 
90  public function sanitizeInt($value, $signed = true) {
91  return $this->db->sanitizeInt($value, $signed);
92  }
93 
97  public function sanitizeString($value) {
98  return $this->db->sanitizeString($value);
99  }
100 
107  public function __get($name) {
108  if ($name === 'prefix') {
109  return $this->db->prefix;
110  }
111 
112  throw new \RuntimeException("Cannot read property '$name'");
113  }
114 
122  public function __set($name, $value) {
123  throw new \RuntimeException("Cannot write property '$name'");
124  }
125 
131  public function fingerprintCallback($callback) {
132  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
133  return $this->db->fingerprintCallback($callback);
134  }
135 
141  public function setTimer(Timer $timer) {
142  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
143  $this->db->setTimer($timer);
144  }
145 
151  public function setLogger(Logger $logger) {
152  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
153  $this->db->setLogger($logger);
154  }
155 
161  public function setupConnections() {
162  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
163  $this->db->setupConnections();
164  }
165 
171  public function connect($type = "readwrite") {
172  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
173  $this->db->connect($type);
174  }
175 
181  public function runSqlScript($scriptlocation) {
182  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
183  $this->db->runSqlScript($scriptlocation);
184  }
185 
191  public function registerDelayedQuery($query, $type, $handler = "", array $params = []) {
192  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
193  return $this->db->registerDelayedQuery($query, $type, $handler, $params);
194  }
195 
201  public function executeDelayedQueries() {
202  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
203  $this->db->executeDelayedQueries();
204  }
205 
211  public function enableQueryCache() {
212  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
213  $this->db->enableQueryCache();
214  }
215 
221  public function disableQueryCache() {
222  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
223  $this->db->disableQueryCache();
224  }
225 
231  public function assertInstalled() {
232  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
233  $this->db->assertInstalled();
234  }
235 
241  public function getQueryCount() {
242  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
243  return $this->db->getQueryCount();
244  }
245 
251  public function getServerVersion($type) {
252  elgg_deprecated_notice(__METHOD__ . " was deprecated and will be removed in 3.0", '2.1');
253  return $this->db->getServerVersion($type);
254  }
255 }
$params
Definition: login.php:72
$handler
Definition: add.php:10
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
setupConnections()
{Establish database connections.If the configuration has been set up for multiple read/write database...
Definition: Database.php:161
getServerVersion($type)
{Get the server version number.Connection type (Config constants, e.g. Config::READ_WRITE)string Empt...
Definition: Database.php:251
executeDelayedQueries()
{Trigger all queries that were registered as "delayed" queries.This is called by the system automatic...
Definition: Database.php:201
fingerprintCallback($callback)
{Get a string that uniquely identifies a callback during the current request.This is used to cache qu...
Definition: Database.php:131
connect($type="readwrite")
{Establish a connection to the database server.Connect to the database server and use the Elgg databa...
Definition: Database.php:171
sanitizeString($value)
{Sanitizes a string for use in a query.Value to escape string }
Definition: Database.php:97
runSqlScript($scriptlocation)
{Runs a full database script from disk.The file specified should be a standard SQL file as created by...
Definition: Database.php:181
setLogger(Logger $logger)
{Set the logger object.The logger void @access private}
Definition: Database.php:151
setTimer(Timer $timer)
{}
Definition: Database.php:141
insertData($query, array $params=[])
{Insert a row into the database.Altering the DB invalidates all queries in the query cache....
Definition: Database.php:58
disableQueryCache()
{Disable the query cache.This is useful for special scripts that pull large amounts of data back in s...
Definition: Database.php:221
getDataRow($query, $callback='', array $params=[])
{Retrieve a single row from the database.Similar to () but returns only the first row matched....
Definition: Database.php:51
deleteData($query, array $params=[])
{Delete data from the database.Altering the DB invalidates all queries in query cache....
Definition: Database.php:72
__construct(ElggDb $db)
Constructor.
Definition: Database.php:37
sanitizeInt($value, $signed=true)
{Sanitizes an integer value for use in a query.Value to sanitize Whether negative values are allowed ...
Definition: Database.php:90
getQueryCount()
{Get the number of queries made to the database.int @access private}
Definition: Database.php:241
updateData($query, $getNumRows=false, array $params=[])
{Update the database.Altering the DB invalidates all queries in the query cache.WARNING!...
Definition: Database.php:65
__get($name)
Handle magic property reads.
Definition: Database.php:107
getTablePrefix()
{Get the value of the "prefix" property.Database::$prefixstring }
Definition: Database.php:80
getData($query, $callback='', array $params=[])
{Retrieve rows from the database.Queries are executed with () and results are retrieved with ()....
Definition: Database.php:44
assertInstalled()
{Test that the Elgg database is installed.void }
Definition: Database.php:231
__set($name, $value)
Handle magic property writes.
Definition: Database.php:122
registerDelayedQuery($query, $type, $handler="", array $params=[])
{Queue a query for execution upon shutdown.You can specify a callback if you care about the result....
Definition: Database.php:191
enableQueryCache()
{Enable the query cache.This does not take precedence over the \Elgg\Database\Config setting....
Definition: Database.php:211
Capture timing info for profiling.
Definition: Timer.php:9
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1098
if(! $display_name) $type
Definition: delete.php:27
$value
Definition: longtext.php:42