Elgg
Version 4.3
|
Public Member Functions | |
__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... | |
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 15 of file Database.php.
Elgg\Application\Database::__construct | ( | ElggDb | $db | ) |
Elgg\Application\Database::__get | ( | $name | ) |
Handle magic property reads.
string | $name | Property name |
Definition at line 150 of file Database.php.
Elgg\Application\Database::__set | ( | $name, | |
$value | |||
) |
Handle magic property writes.
string | $name | Property name |
mixed | $value | Value |
Definition at line 161 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'] |
Definition at line 110 of file Database.php.
Elgg\Application\Database::getConnection | ( | $type | ) |
Gets (if required, also creates) a DB connection.
string | $type | The type of link we want: "read", "write" or "readwrite". |
Definition at line 122 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.
Definition at line 49 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.
Definition at line 66 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'] |
Definition at line 81 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 .
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'] |
Definition at line 140 of file Database.php.
Elgg\Application\Database::updateData | ( | $query, | |
$getNumRows = false , |
|||
array | $params = [] |
||
) |
Update the database.
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'] |
Definition at line 96 of file Database.php.