|
| __construct (ElggDb $db) |
| Constructor. More...
|
|
| getData ($query, $callback= '', array $params=[]) |
| Retrieve rows from the database. More...
|
|
| getDataRow ($query, $callback= '', array $params=[]) |
| Retrieve a single row from the database. More...
|
|
| insertData ($query, array $params=[]) |
| Insert a row into the database. More...
|
|
| updateData ($query, $getNumRows=false, array $params=[]) |
| Update the database. More...
|
|
| deleteData ($query, array $params=[]) |
| Delete data from the database. More...
|
|
| sanitizeInt ($value, $signed=true) |
| Sanitizes an integer value for use in a query. More...
|
|
| sanitizeString ($value) |
| Sanitizes a string for use in a query. More...
|
|
| getConnection ($type) |
| Gets (if required, also creates) a DB connection. More...
|
|
| registerDelayedQuery ($query, $type, $callback=null, array $params=[]) |
| Queue a query for execution upon shutdown. More...
|
|
| __get ($name) |
| Handle magic property reads. More...
|
|
| __set ($name, $value) |
| Handle magic property writes. More...
|
|
Definition at line 16 of file Database.php.
Elgg\Application\Database::__construct |
( |
ElggDb |
$db | ) |
|
Constructor.
- Parameters
-
ElggDb | $db | The Elgg database |
Definition at line 30 of file Database.php.
Elgg\Application\Database::__get |
( |
|
$name | ) |
|
Handle magic property reads.
- Parameters
-
- Returns
- mixed
Definition at line 183 of file Database.php.
Elgg\Application\Database::__set |
( |
|
$name, |
|
|
|
$value |
|
) |
| |
Handle magic property writes.
- Parameters
-
string | $name | Property name |
mixed | $value | Value |
- Returns
- void
Definition at line 194 of file Database.php.
Elgg\Application\Database::deleteData |
( |
|
$query, |
|
|
array |
$params = [] |
|
) |
| |
Delete data from the database.
- Note
- Altering the DB invalidates all queries in query cache.
- Parameters
-
string | $query | The SQL query to run |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
- Returns
- int The number of affected rows
- Exceptions
-
Definition at line 118 of file Database.php.
Elgg\Application\Database::getConnection |
( |
|
$type | ) |
|
Gets (if required, also creates) a DB connection.
- Parameters
-
string | $type | The type of link we want: "read", "write" or "readwrite". |
- Returns
- Connection
- Exceptions
-
Definition at line 155 of file Database.php.
Elgg\Application\Database::getData |
( |
|
$query, |
|
|
|
$callback = '' , |
|
|
array |
$params = [] |
|
) |
| |
Retrieve rows from the database.
Queries are executed with Elgg\Database::executeQuery()andresultsareretrievedwith@link\PDO::fetchObject().Ifacallbackfunction$callbackisdefined,eachrowwillbepassedasasingleargumentto$callback.Ifnocallbackfunctionisdefined,theentireresultsetisreturnedasanarray.@paramstring$queryThequerybeingpassed.@paramcallable$callbackOptionally,thenameofafunctiontocallbacktooneachrow@paramarray$paramsQueryparams.E.g.[1,'steve']or[':id'=>1,':name'=>'steve']@returnarrayAnarrayofdatabaseresultobjectsorcallbackfunctionresults.Ifthequeryreturnednothing,anemptyarray.@throwsDatabaseException
Definition at line 51 of file Database.php.
Elgg\Application\Database::getDataRow |
( |
|
$query, |
|
|
|
$callback = '' , |
|
|
array |
$params = [] |
|
) |
| |
Retrieve a single row from the database.
Similar to Elgg\Database::getData()butreturnsonlythefirstrowmatched.Ifacallbackfunction$callbackisspecified,therowwillbepassedastheonlyargumentto$callback.@paramstring$queryThequerytoexecute.@paramcallable$callbackAcallbackfunctiontoapplytotherow@paramarray$paramsQueryparams.E.g.[1,'steve']or[':id'=>1,':name'=>'steve']@returnmixedAsingledatabaseresultobjectortheresultofthecallbackfunction.@throwsDatabaseException
Definition at line 69 of file Database.php.
Elgg\Application\Database::insertData |
( |
|
$query, |
|
|
array |
$params = [] |
|
) |
| |
Insert a row into the database.
- Note
- Altering the DB invalidates all queries in the query cache.
- Parameters
-
string | $query | The query to execute. |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
- Returns
- int|false The database id of the inserted row if a AUTO_INCREMENT field is defined, 0 if not, and false on failure.
- Exceptions
-
Definition at line 85 of file Database.php.
Elgg\Application\Database::registerDelayedQuery |
( |
|
$query, |
|
|
|
$type, |
|
|
|
$callback = null , |
|
|
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 .
- Parameters
-
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'] |
- Returns
- boolean Whether registering was successful.
Definition at line 173 of file Database.php.
Elgg\Application\Database::sanitizeInt |
( |
|
$value, |
|
|
|
$signed = true |
|
) |
| |
Sanitizes an integer value for use in a query.
- Parameters
-
int | $value | Value to sanitize |
bool | $signed | Whether negative values are allowed (default: true) |
- Returns
- int
Definition at line 130 of file Database.php.
Elgg\Application\Database::sanitizeString |
( |
|
$value | ) |
|
Sanitizes a string for use in a query.
- Parameters
-
string | $value | Value to escape |
- Returns
- string
- Exceptions
-
Definition at line 142 of file Database.php.
Elgg\Application\Database::updateData |
( |
|
$query, |
|
|
|
$getNumRows = false , |
|
|
array |
$params = [] |
|
) |
| |
Update the database.
- Note
- Altering the DB invalidates all queries in the query cache.
-
WARNING! update_data() has the 2nd and 3rd arguments reversed.
- Parameters
-
string | $query | The query to run. |
bool | $getNumRows | Return the number of rows affected (default: false). |
array | $params | Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
- Returns
- bool|int
- Exceptions
-
Definition at line 103 of file Database.php.
The documentation for this class was generated from the following file: