Elgg
Version 2.3
|
Public Member Functions | |||||||||||||
__construct (ElggDb $db) | |||||||||||||
Constructor. More... | |||||||||||||
getData ($query, $callback='', array $params=[]) | |||||||||||||
{Retrieve rows from the database.Queries are executed with () and results are retrieved with (). If a callback function $callback is defined, each row will be passed as a single argument to $callback. If no callback function is defined, the entire result set is returned as an array.
| |||||||||||||
getDataRow ($query, $callback='', array $params=[]) | |||||||||||||
{Retrieve a single row from the database.Similar to () 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.
| |||||||||||||
insertData ($query, array $params=[]) | |||||||||||||
{Insert a row into the database.
| |||||||||||||
updateData ($query, $getNumRows=false, array $params=[]) | |||||||||||||
{Update the database.
| |||||||||||||
deleteData ($query, array $params=[]) | |||||||||||||
{Delete data from the database.
| |||||||||||||
getTablePrefix () | |||||||||||||
{Get the value of the "prefix" property.
| |||||||||||||
sanitizeInt ($value, $signed=true) | |||||||||||||
{Sanitizes an integer value for use in a query.
| |||||||||||||
sanitizeString ($value) | |||||||||||||
{Sanitizes a string for use in a query.
| |||||||||||||
__get ($name) | |||||||||||||
Handle magic property reads. More... | |||||||||||||
__set ($name, $value) | |||||||||||||
Handle magic property writes. More... | |||||||||||||
fingerprintCallback ($callback) | |||||||||||||
{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.
| |||||||||||||
setTimer (Timer $timer) | |||||||||||||
{} More... | |||||||||||||
setLogger (Logger $logger) | |||||||||||||
{Set the logger object.
| |||||||||||||
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.
| |||||||||||||
connect ($type="readwrite") | |||||||||||||
{Establish a connection to the database server.Connect to the database server and use the Elgg database for a particular database link
| |||||||||||||
runSqlScript ($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 \r ).The special string 'prefix_' is replaced with the database prefix as defined in ->tablePrefix.
| |||||||||||||
registerDelayedQuery ($query, $type, $handler="", array $params=[]) | |||||||||||||
{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 \Doctrine\DBAL\Driver\Statement.
| |||||||||||||
executeDelayedQueries () | |||||||||||||
{Trigger all queries that were registered as "delayed" queries.This is called by the system automatically on shutdown.
| |||||||||||||
enableQueryCache () | |||||||||||||
{Enable the query cache.This does not take precedence over the \Elgg\Database\Config setting.
| |||||||||||||
disableQueryCache () | |||||||||||||
{Disable the query cache.This is useful for special scripts that pull large amounts of data back in single queries.
| |||||||||||||
assertInstalled () | |||||||||||||
{Test that the Elgg database is installed.
| |||||||||||||
getQueryCount () | |||||||||||||
{Get the number of queries made to the database.
| |||||||||||||
getServerVersion ($type) | |||||||||||||
{Get the server version number.
| |||||||||||||
![]() | |||||||||||||
__construct (\Elgg\Database\Config $config, \Elgg\Logger $logger=null) | |||||||||||||
Constructor. More... | |||||||||||||
Additional Inherited Members | |
![]() | |
const | DELAYED_QUERY = 'q' |
const | DELAYED_TYPE = 't' |
const | DELAYED_HANDLER = 'h' |
const | DELAYED_PARAMS = 'p' |
![]() | |
getConnection ($type) | |
Gets (if required, also creates) a DB connection. More... | |
getResults ($query, $callback=null, $single=false, array $params=[]) | |
Handles queries that return results, running the results through a an optional callback function. More... | |
executeQuery ($query, Connection $connection, array $params=[]) | |
Execute a query. More... | |
invalidateQueryCache () | |
Invalidate the query cache. More... | |
Definition at line 22 of file Database.php.
Elgg\Application\Database::__construct | ( | ElggDb | $db | ) |
Constructor.
ElggDb | $db | The Elgg database @access private |
Definition at line 37 of file Database.php.
Elgg\Application\Database::__get | ( | $name | ) |
Handle magic property reads.
string | $name | Property name |
Reimplemented from Elgg\Database.
Definition at line 107 of file Database.php.
Elgg\Application\Database::__set | ( | $name, | |
$value | |||
) |
Handle magic property writes.
string | $name | Property name |
mixed | $value | Value |
Reimplemented from Elgg\Database.
Definition at line 122 of file Database.php.
Elgg\Application\Database::assertInstalled | ( | ) |
{Test that the Elgg database is installed.
Reimplemented from Elgg\Database.
Definition at line 231 of file Database.php.
Elgg\Application\Database::connect | ( | $type = "readwrite" | ) |
{Establish a connection to the database server.Connect to the database server and use the Elgg database for a particular database link
string | $type | The type of database connection. "read", "write", or "readwrite". |
Reimplemented from Elgg\Database.
Definition at line 171 of file Database.php.
Elgg\Application\Database::deleteData | ( | $query, | |
array | $params = [] |
||
) |
{Delete data from the database.
string | $query | The SQL query to run |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Reimplemented from Elgg\Database.
Definition at line 72 of file Database.php.
Elgg\Application\Database::disableQueryCache | ( | ) |
{Disable the query cache.This is useful for special scripts that pull large amounts of data back in single queries.
Reimplemented from Elgg\Database.
Definition at line 221 of file Database.php.
Elgg\Application\Database::enableQueryCache | ( | ) |
{Enable the query cache.This does not take precedence over the \Elgg\Database\Config setting.
Reimplemented from Elgg\Database.
Definition at line 211 of file Database.php.
Elgg\Application\Database::executeDelayedQueries | ( | ) |
{Trigger all queries that were registered as "delayed" queries.This is called by the system automatically on shutdown.
Reimplemented from Elgg\Database.
Definition at line 201 of file Database.php.
Elgg\Application\Database::fingerprintCallback | ( | $callback | ) |
{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.
callable | $callback | The callable value to fingerprint |
Reimplemented from Elgg\Database.
Definition at line 131 of file Database.php.
Elgg\Application\Database::getData | ( | $query, | |
$callback = '' , |
|||
array | $params = [] |
||
) |
{Retrieve rows from the database.Queries are executed with () and results are retrieved with (). If a callback function $callback is defined, each row will be passed as a single argument to $callback. If no callback function is defined, the entire result set is returned as an array.
string | $query | The query being passed. |
callable | $callback | Optionally, the name of a function to call back to on each row |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Reimplemented from Elgg\Database.
Definition at line 44 of file Database.php.
Elgg\Application\Database::getDataRow | ( | $query, | |
$callback = '' , |
|||
array | $params = [] |
||
) |
{Retrieve a single row from the database.Similar to () 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'] |
Reimplemented from Elgg\Database.
Definition at line 51 of file Database.php.
Elgg\Application\Database::getQueryCount | ( | ) |
{Get the number of queries made to the database.
Reimplemented from Elgg\Database.
Definition at line 241 of file Database.php.
Elgg\Application\Database::getServerVersion | ( | $type | ) |
{Get the server version number.
string | $type | Connection type (Config constants, e.g. Config::READ_WRITE) |
Reimplemented from Elgg\Database.
Definition at line 251 of file Database.php.
Elgg\Application\Database::getTablePrefix | ( | ) |
{Get the value of the "prefix" property.
Reimplemented from Elgg\Database.
Definition at line 80 of file Database.php.
Elgg\Application\Database::insertData | ( | $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'] |
Reimplemented from Elgg\Database.
Definition at line 58 of file Database.php.
Elgg\Application\Database::registerDelayedQuery | ( | $query, | |
$type, | |||
$handler = "" , |
|||
array | $params = [] |
||
) |
{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 \Doctrine\DBAL\Driver\Statement.
string | $query | The query to execute |
string | $type | The query type ('read' or 'write') |
callable | $callback | A callback function to pass the results array to |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Reimplemented from Elgg\Database.
Definition at line 191 of file Database.php.
Elgg\Application\Database::runSqlScript | ( | $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 \r
).The special string 'prefix_' is replaced with the database prefix as defined in ->tablePrefix.
string | $scriptlocation | The full path to the script |
Reimplemented from Elgg\Database.
Definition at line 181 of file Database.php.
Elgg\Application\Database::sanitizeInt | ( | $value, | |
$signed = true |
|||
) |
{Sanitizes an integer value for use in a query.
int | $value | Value to sanitize |
bool | $signed | Whether negative values are allowed (default: true) |
Reimplemented from Elgg\Database.
Definition at line 90 of file Database.php.
Elgg\Application\Database::sanitizeString | ( | $value | ) |
{Sanitizes a string for use in a query.
string | $value | Value to escape |
Reimplemented from Elgg\Database.
Definition at line 97 of file Database.php.
Elgg\Application\Database::setLogger | ( | Logger | $logger | ) |
{Set the logger object.
Logger | $logger | The logger |
Reimplemented from Elgg\Database.
Definition at line 151 of file Database.php.
Elgg\Application\Database::setTimer | ( | Timer | $timer | ) |
{}
Definition at line 141 of file Database.php.
Elgg\Application\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.
Reimplemented from Elgg\Database.
Definition at line 161 of file Database.php.
Elgg\Application\Database::updateData | ( | $query, | |
$getNumRows = false , |
|||
array | $params = [] |
||
) |
{Update the database.
string | $query | The query to run. |
bool | $get_num_rows | Return the number of rows affected (default: false). |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
Reimplemented from Elgg\Database.
Definition at line 65 of file Database.php.