spunQ_IDatabaseConnection Interface Reference
Provides access to a database.
More...
List of all members.
|
Public Member Functions |
| | startTransaction () |
| | Starts a transaction.
|
| | commitTransaction () |
| | Commits a pending transaction.
|
| | rollbackTransaction () |
| | Cancels the current transaction.
|
| | createTypeStorage (spunQ_UserType $type) |
| | Creates type storages for a type.
|
| | getAllTypeStorages () |
| | Will return all available type storages, mapped by the type names.
|
| | getTypeStorage ($type, $throwException=true) |
| | Will return the type storage of a certain type.
|
| | addDatabaseListener (spunQ_IDatabaseListener $listener, $types=NULL) |
| | Adds an observer to the database connection.
|
| | removeDatabaseListener (spunQ_IDatabaseListener $listener, $types=NULL) |
| | Removes an observer from the database connection.
|
| | executeInsertQuery (spunQ_InsertQuery $query) |
| | Execute an insert query.
|
| | executeSelectQuery (spunQ_SelectQuery $query, array $parameters=array()) |
| | Execute a select query.
|
| | countSelectQuery (spunQ_SelectQuery $query, array $parameters=array()) |
| | Returns number of matching objects for a select query.
|
| | executeUpdateQuery (spunQ_UpdateQuery $query, array $parameters=array()) |
| | Execute an update query.
|
| | executeDeleteQuery (spunQ_DeleteQuery $query, array $parameters=array()) |
| | Execute a delete query.
|
| | getAll ($typeName) |
| | Retrieves all objects of given type.
|
| | getByCondition ($typeName, $condition, $parameters) |
| | Retrieves all objects meeting a given condition.
|
| | getByMember ($typeName, $memberName, $value) |
| | Retrieves all objects where a member has given value.
|
| | getById ($id, $typeName=NULL, $throwException=true) |
| | Retrieves the object with given id.
|
| | getByIds (array $ids, $typeName=NULL) |
| | Retrieves the object with the requested ids.
|
| | loadOnDemand ($object, array $members) |
| | Intended for internal use only.
|
Detailed Description
Provides access to a database.
Definition at line 6 of file IDatabaseConnection.interface.php.
Member Function Documentation
Adds an observer to the database connection.
- Parameters:
-
| $listener | The observer. |
| $types | The types to listen on. NULL for all types |
- Returns:
- spunQ_IDatabaseConnection $this
| spunQ_IDatabaseConnection::commitTransaction |
( |
|
) |
|
Commits a pending transaction.
- Returns:
- void
| spunQ_IDatabaseConnection::countSelectQuery |
( |
spunQ_SelectQuery $ |
query, |
|
|
array $ |
parameters = array() | |
|
) |
| | |
Returns number of matching objects for a select query.
- Parameters:
-
| $query | The query to execute |
| $parameters | Parameters to PL strings in the query. |
- Returns:
- integer
- Exceptions:
-
| spunQ_IDatabaseConnection::createTypeStorage |
( |
spunQ_UserType $ |
type |
) |
|
Creates type storages for a type.
- Parameters:
-
| $type | Type to create storage for. |
- Exceptions:
-
| spunQ_TypeStorageNotFoundException | If the type storage for its parent type does not exist. |
| spunQ_TypeStorageAlreadyExistsException | If the type storage for this type already exists. |
| spunQ_DatabaseException | On all other database errors. |
- Returns:
- spunQ.db.ITypeStorage
| spunQ_IDatabaseConnection::executeDeleteQuery |
( |
spunQ_DeleteQuery $ |
query, |
|
|
array $ |
parameters = array() | |
|
) |
| | |
Execute a delete query.
- Parameters:
-
| $query | The query to execute |
| $parameters | Parameters to PL strings in the query. |
- Returns:
- Whatever the query is configured to return.
- Exceptions:
-
Execute an insert query.
- Parameters:
-
| $query | The query to execute |
- Returns:
- Whatever the query is configured to return.
- Exceptions:
-
| spunQ_IDatabaseConnection::executeSelectQuery |
( |
spunQ_SelectQuery $ |
query, |
|
|
array $ |
parameters = array() | |
|
) |
| | |
Execute a select query.
- Parameters:
-
| $query | The query to execute |
| $parameters | Parameters to PL strings in the query. |
- Returns:
- Whatever the query is configured to return.
- Exceptions:
-
| spunQ_IDatabaseConnection::executeUpdateQuery |
( |
spunQ_UpdateQuery $ |
query, |
|
|
array $ |
parameters = array() | |
|
) |
| | |
Execute an update query.
- Parameters:
-
| $query | The query to execute |
| $parameters | Parameters to PL strings in the query. |
- Returns:
- Whatever the query is configured to return.
- Exceptions:
-
| spunQ_IDatabaseConnection::getAll |
( |
$ |
typeName |
) |
|
Retrieves all objects of given type.
- Parameters:
-
| $typeName | Name of the type to retrieve objects for. |
- Returns:
- array<spunQ.db.StorableObject>
| spunQ_IDatabaseConnection::getAllTypeStorages |
( |
|
) |
|
Will return all available type storages, mapped by the type names.
- Returns:
- map<string,spunQ_ITypeStorage>
- Exceptions:
-
| spunQ_IDatabaseConnection::getByCondition |
( |
$ |
typeName, |
|
|
$ |
condition, |
|
|
$ |
parameters | |
|
) |
| | |
Retrieves all objects meeting a given condition.
- Parameters:
-
| $typeName | Name of the type to retrieve objects for. |
| $condition | The PL string to check on the stored objects. |
| $parameters | Paramters to the PL string. |
- Returns:
- array<spunQ.db.StorableObject>
| spunQ_IDatabaseConnection::getById |
( |
$ |
id, |
|
|
$ |
typeName = NULL, |
|
|
$ |
throwException = true | |
|
) |
| | |
Retrieves the object with given id.
- Parameters:
-
| $id | The id to retrieve. This is the only mandatory parameter - everything else is optional. |
| $typeName | The name of the type the object should have. Defaults to spunQ.db.StorableObject. Providing this value will allow the underlying database manager to cache more efficiently. |
| $throwException | Whether the function should throw an exception if no object with the given id was found. Will return NULL in that case if this value is false. |
- Returns:
- spunQ.db.StorableObject
- Exceptions:
-
| spunQ_IDatabaseConnection::getByIds |
( |
array $ |
ids, |
|
|
$ |
typeName = NULL | |
|
) |
| | |
Retrieves the object with the requested ids.
- See also:
- getById()
- Parameters:
-
| $id | The ids to retrieve. |
| $typeName | The name of the type the objects should have. Defaults to spunQ.db.StorableObject. Providing this value will allow the underlying database manager to cache more efficiently. |
- Returns:
- array<spunQ.db.StorableObject> Keys of the array are the ids of the objects.
| spunQ_IDatabaseConnection::getByMember |
( |
$ |
typeName, |
|
|
$ |
memberName, |
|
|
$ |
value | |
|
) |
| | |
Retrieves all objects where a member has given value.
This is basically the same as calling getByCondition($typeName, "$memberName = {0}", array($value)).
- Parameters:
-
| $typeName | Name of the type to retrieve objects for. |
| $memberName | Name of the member to check. |
| $value | Value the provided member must have to be returned. |
- Returns:
- array<spunQ.db.StorableObject>
| spunQ_IDatabaseConnection::getTypeStorage |
( |
$ |
type, |
|
|
$ |
throwException = true | |
|
) |
| | |
Will return the type storage of a certain type.
- Parameters:
-
| $type | The type to get storage for. This is either a string describing a type or a spunQ_Type object. |
| $throwException | Whether the function should throw an exception if no type storage for given type was found. Will return NULL in that case if this value is false. |
- Returns:
- spunQ_ITypeStorage
- Exceptions:
-
| spunQ_IDatabaseConnection::loadOnDemand |
( |
$ |
object, |
|
|
array $ |
members | |
|
) |
| | |
Intended for internal use only.
spunQ.db.StorableObject needs to call this function to load missing members from the database. The connection will call spunQ_StorableObject::_loadRemoteValues() on the $object. It is perfectly valid for this connection to load additional members if this reduces overall query overhead.
- Parameters:
-
| $object | The object to load members for. It must have an id. |
| $members | Names of the members that needs to be loaded. The first entry in this array is needed, all others are further members that have not yet been loaded. The database is free to load any of these additional members. |
- Returns:
- spunQ_IDatabaseConnection $this
Removes an observer from the database connection.
- Parameters:
-
| $listener | The observer. |
| $types | The types to listen on. NULL for all types |
- Returns:
- spunQ_IDatabaseConnection $this
| spunQ_IDatabaseConnection::rollbackTransaction |
( |
|
) |
|
Cancels the current transaction.
- Returns:
- void
| spunQ_IDatabaseConnection::startTransaction |
( |
|
) |
|
Starts a transaction.
- Exceptions:
-
- Returns:
- void
The documentation for this interface was generated from the following file: