Elgg  Version 6.0
Public Member Functions | List of all members
Elgg\Application\Database Class Reference

Public Member Functions

 __construct (protected ElggDb $db)
 Constructor. More...
 
 getData (QueryBuilder $query, $callback= '')
 Retrieve rows from the database. More...
 
 getDataRow (QueryBuilder $query, $callback= '')
 Retrieve a single row from the database. More...
 
 insertData (QueryBuilder $query)
 Insert a row into the database. More...
 
 updateData (QueryBuilder $query, bool $getNumRows=false)
 Update the database. More...
 
 deleteData (QueryBuilder $query)
 Delete data from the database. More...
 
 getConnection ($type)
 Gets (if required, also creates) a DB connection. More...
 
 registerDelayedQuery (QueryBuilder $query, $callback=null)
 Queue a query for execution upon shutdown. More...
 
 __get ($name)
 Handle magic property reads. More...
 
 __set ($name, $value)
 Handle magic property writes. More...
 

Detailed Description

Definition at line 16 of file Database.php.

Constructor & Destructor Documentation

Elgg\Application\Database::__construct ( protected ElggDb  $db)

Constructor.

Parameters
ElggDb$dbThe Elgg database

Definition at line 23 of file Database.php.

Member Function Documentation

Elgg\Application\Database::__get (   $name)

Handle magic property reads.

Parameters
string$nameProperty name
Returns
mixed

Definition at line 136 of file Database.php.

Elgg\Application\Database::__set (   $name,
  $value 
)

Handle magic property writes.

Parameters
string$nameProperty name
mixed$valueValue
Returns
void

Definition at line 147 of file Database.php.

Elgg\Application\Database::deleteData ( QueryBuilder  $query)

Delete data from the database.

Note
Altering the DB invalidates all queries in query cache.
Parameters
QueryBuilder$queryThe SQL query to run
Returns
int The number of affected rows

Definition at line 98 of file Database.php.

Elgg\Application\Database::getConnection (   $type)

Gets (if required, also creates) a DB connection.

Parameters
string$typeThe type of link we want: "read", "write" or "readwrite".
Returns
Connection

Definition at line 110 of file Database.php.

Elgg\Application\Database::getData ( QueryBuilder  $query,
  $callback = '' 
)

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 41 of file Database.php.

Elgg\Application\Database::getDataRow ( QueryBuilder  $query,
  $callback = '' 
)

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 57 of file Database.php.

Elgg\Application\Database::insertData ( QueryBuilder  $query)

Insert a row into the database.

Note
Altering the DB invalidates all queries in the query cache.
Parameters
QueryBuilder$queryThe query to execute
Returns
int|false The database id of the inserted row if a AUTO_INCREMENT field is defined, 0 if not, and false on failure.

Definition at line 71 of file Database.php.

Elgg\Application\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$queryThe query to execute
callable$callbackA callback function to pass the results array to
Returns
void

Definition at line 126 of file Database.php.

Elgg\Application\Database::updateData ( QueryBuilder  $query,
bool  $getNumRows = false 
)

Update the database.

Note
Altering the DB invalidates all queries in the query cache.
Parameters
QueryBuilder$queryThe query to run.
bool$getNumRowsReturn the number of rows affected (default: false).
Returns
bool|int

Definition at line 85 of file Database.php.


The documentation for this class was generated from the following file: