The Elgg database.
More...
The Elgg database.
Definition at line 26 of file Database.php.
Elgg\Database::__get |
( |
|
$name | ) |
|
Handle magic property reads.
- Parameters
-
- Returns
- mixed
- Exceptions
-
Definition at line 594 of file Database.php.
Elgg\Database::__set |
( |
|
$name, |
|
|
|
$value |
|
) |
| |
Handle magic property writes.
- Parameters
-
string | $name | Property name |
mixed | $value | Value |
- Returns
- void
- Exceptions
-
Definition at line 611 of file Database.php.
Elgg\Database::closeConnections |
( |
| ) |
|
Close all database connections.
Note: this is only meant to be used in the PHPUnit test suites
- Returns
- void
- Since
- 4.1
Definition at line 98 of file Database.php.
Elgg\Database::connect |
( |
string |
$type = 'readwrite' | ) |
|
Establish a connection to the database server.
Connect to the database server and use the Elgg database for a particular database link
- Parameters
-
string | $type | The type of database connection. "read", "write", or "readwrite". |
- Returns
- void
- Exceptions
-
Definition at line 152 of file Database.php.
Delete data from the database.
- Note
- Altering the DB invalidates all queries in query cache.
- Parameters
-
- Returns
- int The number of affected rows
Definition at line 286 of file Database.php.
Elgg\Database::executeDelayedQueries |
( |
| ) |
|
Trigger all queries that were registered as "delayed" queries.
This is called by the system automatically on shutdown.
- Returns
- void
Definition at line 521 of file Database.php.
Elgg\Database::fingerprintCallback |
( |
|
$callback | ) |
|
|
protected |
Get a string that uniquely identifies a callback during the current request.
This is used to cache queries whose results were transformed by the callback. If the callback involves object method calls of the same class, different instances will return different values.
- Parameters
-
callable | $callback | The callable value to fingerprint |
- Returns
- string A string that is unique for each callable passed in
- Since
- 1.9.4
Definition at line 309 of file Database.php.
Elgg\Database::getCacheHash |
( |
string |
$sql, |
|
|
array |
$params = [] , |
|
|
string |
$extras = '' |
|
) |
| |
|
protected |
Returns a hashed key for storage in the cache.
- Parameters
-
string | $sql | query |
array | $params | optional params |
string | $extras | optional extras |
- Returns
- string
- Since
- 6.1
Definition at line 432 of file Database.php.
Elgg\Database::getConnection |
( |
string |
$type | ) |
|
Gets (if required, also creates) a DB connection.
- Parameters
-
string | $type | The type of link we want: "read", "write" or "readwrite". |
- Returns
- Connection
Definition at line 113 of file Database.php.
Elgg\Database::getData |
( |
QueryBuilder |
$query, |
|
|
|
$callback = null |
|
) |
| |
Retrieve rows from the database.
Queries are executed with Elgg\Database::executeQuery()andresultsareretrievedwith@link\PDO::fetchObject().Ifacallbackfunction$callbackisdefined,eachrowwillbepassedasasingleargumentto$callback.Ifnocallbackfunctionisdefined,theentireresultsetisreturnedasanarray.@paramQueryBuilder$queryThequerybeingpassed.@paramcallable$callbackOptionally,thenameofafunctiontocallbacktooneachrow@returnarrayAnarrayofdatabaseresultobjectsorcallbackfunctionresults.Ifthequeryreturnednothing,anemptyarray.
Definition at line 200 of file Database.php.
Elgg\Database::getDataRow |
( |
QueryBuilder |
$query, |
|
|
|
$callback = null |
|
) |
| |
Retrieve a single row from the database.
Similar to Elgg\Database::getData()butreturnsonlythefirstrowmatched.Ifacallbackfunction$callbackisspecified,therowwillbepassedastheonlyargumentto$callback.@paramQueryBuilder$queryThequerytoexecute.@paramcallable$callbackAcallbackfunctiontoapplytotherow@returnmixedAsingledatabaseresultobjectortheresultofthecallbackfunction.
Definition at line 216 of file Database.php.
Elgg\Database::getQueryCount |
( |
| ) |
|
Get the number of queries made to the database.
- Returns
- int
Definition at line 547 of file Database.php.
Elgg\Database::getResults |
( |
QueryBuilder |
$query, |
|
|
|
$callback = null , |
|
|
bool |
$single = false |
|
) |
| |
|
protected |
Handles queries that return results, running the results through a an optional callback function.
This is for R queries (from CRUD).
- Parameters
-
QueryBuilder | $query | The select query to execute |
callable | $callback | An optional callback function to run on each row |
bool | $single | Return only a single result? |
- Returns
- array| An array of database result objects or callback function results. If the query returned nothing, an empty array.
- Exceptions
-
Definition at line 342 of file Database.php.
Get the server version number.
- Parameters
-
string | $type | Connection type (Config constants, e.g. Config::READ_WRITE) |
- Returns
- string Empty if version cannot be determined
Definition at line 558 of file Database.php.
Insert a row into the database.
- Note
- Altering the DB invalidates all queries in the query cache.
- Parameters
-
- Returns
- int The database id of the inserted row if a AUTO_INCREMENT field is defined, 0 if not
Definition at line 229 of file Database.php.
Is the database MariaDB.
- Parameters
-
string | $type | Connection type (Config constants, e.g. Config::READ_WRITE) |
- Returns
- bool if MariaDB is detected
Definition at line 569 of file Database.php.
Is the database MySQL.
- Parameters
-
string | $type | Connection type (Config constants, e.g. Config::READ_WRITE) |
- Returns
- bool if MySQL is detected
- Since
- 6.0
Definition at line 582 of file Database.php.
Elgg\Database::registerDelayedQuery |
( |
QueryBuilder |
$query, |
|
|
|
$callback = null |
|
) |
| |
Queue a query for execution upon shutdown.
You can specify a callback if you care about the result. This function will always be passed a .
- Parameters
-
QueryBuilder | $query | The query to execute |
callable | $callback | A callback function to pass the results array to |
- Returns
- void
Definition at line 490 of file Database.php.
Elgg\Database::resetConnections |
( |
DbConfig |
$config | ) |
|
Reset the connections with new credentials.
- Parameters
-
- Returns
- void
Definition at line 81 of file Database.php.
Elgg\Database::setupConnections |
( |
| ) |
|
Establish database connections.
If the configuration has been set up for multiple read/write databases, set those links up separately; otherwise just create the one database link.
- Returns
- void
Definition at line 133 of file Database.php.
Elgg\Database::trackQuery |
( |
QueryBuilder |
$query, |
|
|
callable |
$callback |
|
) |
| |
Tracks the query count and timers for a given query.
- Parameters
-
QueryBuilder | $query | The query |
callable | $callback | Callback to execyte during query execution |
- Returns
- mixed
Definition at line 452 of file Database.php.
Elgg\Database::updateData |
( |
QueryBuilder |
$query, |
|
|
bool |
$get_num_rows = false |
|
) |
| |
Update the database.
- Note
- Altering the DB invalidates all queries in the query cache.
- Parameters
-
QueryBuilder | $query | The query to run. |
bool | $get_num_rows | Return the number of rows affected (default: false). |
- Returns
- bool|int
Definition at line 261 of file Database.php.
array Elgg\Database::$connections = [] |
|
protected |
Elgg\Database::$db_config |
|
protected |
array Elgg\Database::$delayed_queries = [] |
|
protected |
int Elgg\Database::$query_count = 0 |
|
protected |
Elgg\Database::$table_prefix |
|
protected |
const Elgg\Database::DELAYED_HANDLER = 'h' |
const Elgg\Database::DELAYED_QUERY = 'q' |
The documentation for this class was generated from the following file: