Mapper¶
-
class
OCP\AppFramework\Db\Mapper¶ - Simple parent class for inheriting your data access layer from. This classmay be subject to change in the future
Source: lib/public/AppFramework/Db/Mapper.php#39
Properties¶
-
protected static property
OCP\AppFramework\Db\Mapper::$tableName¶ Source: lib/public/AppFramework/Db/Mapper.php#40
-
protected static property
OCP\AppFramework\Db\Mapper::$entityClass¶ Source: lib/public/AppFramework/Db/Mapper.php#41
-
protected static property
OCP\AppFramework\Db\Mapper::$db¶ Source: lib/public/AppFramework/Db/Mapper.php#42
Methods¶
-
public
OCP\AppFramework\Db\Mapper::__construct($db, $tableName, $entityClass=null)¶ Source: Parameters: - $db (
OCP\IDBConnection) Instance of the Db abstraction layer - $tableName (string) the name of the table. set this to allow entity
- $entityClass (string) the name of the entity that the sql should be
mapped to queries without using sql
Since: 7.0.0
Deprecated: 14.0.0 Move over to QBMapper
- $db (
-
public
OCP\AppFramework\Db\Mapper::getTableName()¶ Source: lib/public/AppFramework/Db/Mapper.php#71 Returns: string the table name Since: 7.0.0 Deprecated: 14.0.0 Move over to QBMapper
-
public
OCP\AppFramework\Db\Mapper::delete($entity)¶ - Deletes an entity from the table
Source: Parameters: - $entity (
OCP\AppFramework\Db\Entity) the entity that should be deleted
Returns: \OCP\AppFramework\Db\Entitythe deleted entitySince: 7.0.0 - return value added in 8.1.0
Deprecated: 14.0.0 Move over to QBMapper
- $entity (
-
public
OCP\AppFramework\Db\Mapper::insert($entity)¶ - Creates a new entry in the db from an entity
Source: Parameters: - $entity (
OCP\AppFramework\Db\Entity) the entity that should be created
Returns: \OCP\AppFramework\Db\Entitythe saved entity with the set idSince: 7.0.0
Deprecated: 14.0.0 Move over to QBMapper
- $entity (
-
public
OCP\AppFramework\Db\Mapper::update($entity)¶ - Updates an entry in the db from an entity
Source: Parameters: - $entity (
OCP\AppFramework\Db\Entity) the entity that should be created
Throws: \InvalidArgumentExceptionif entity has no idReturns: \OCP\AppFramework\Db\Entitythe saved entity with the set idSince: 7.0.0 - return value was added in 8.0.0
Deprecated: 14.0.0 Move over to QBMapper
- $entity (
-
protected
OCP\AppFramework\Db\Mapper::execute($sql, $params=[], $limit=null, $offset=null)¶ - Runs an sql query
Source: Parameters: - $sql (string) the prepare string
- $params (array) the params which should replace the ? in the sql query
- $limit (int) the maximum number of rows
- $offset (int) from which row we want to start
Returns: \PDOStatementthe database query resultSince: 7.0.0
Deprecated: 14.0.0 Move over to QBMapper
-
protected
OCP\AppFramework\Db\Mapper::findOneQuery($sql, $params=[], $limit=null, $offset=null)¶ - Returns an db result and throws exceptions when there are more or lessresults
Source: Parameters: - $sql (string) the sql query
- $params (array) the parameters of the sql query
- $limit (int) the maximum number of rows
- $offset (int) from which row we want to start
See: \OCP\AppFramework\Db\findEntityThrows: \OCP\AppFramework\Db\DoesNotExistExceptionif the item does not existThrows: \OCP\AppFramework\Db\MultipleObjectsReturnedExceptionif more than one item existThrows: \OCP\AppFramework\Db\DoesNotExistExceptionif the item does not existThrows: \OCP\AppFramework\Db\MultipleObjectsReturnedExceptionif more than one item existReturns: array the result as row
Since: 7.0.0
Deprecated: 14.0.0 Move over to QBMapper
-
protected
OCP\AppFramework\Db\Mapper::mapRowToEntity($row)¶ - Creates an entity from a row. Automatically determines the entity classfrom the current mapper name (MyEntityMapper -> MyEntity)
Source: Parameters: - $row (array) the row which should be converted to an entity
Returns: \OCP\AppFramework\Db\Entitythe entitySince: 7.0.0
Deprecated: 14.0.0 Move over to QBMapper
-
protected
OCP\AppFramework\Db\Mapper::findEntities($sql, $params=[], $limit=null, $offset=null)¶ - Runs a sql query and returns an array of entities
Source: Parameters: - $sql (string) the prepare string
- $params (array) the params which should replace the ? in the sql query
- $limit (int) the maximum number of rows
- $offset (int) from which row we want to start
Returns: array all fetched entities
Since: 7.0.0
Deprecated: 14.0.0 Move over to QBMapper
-
protected
OCP\AppFramework\Db\Mapper::findEntity($sql, $params=[], $limit=null, $offset=null)¶ - Returns an db result and throws exceptions when there are more or lessresults
Source: Parameters: - $sql (string) the sql query
- $params (array) the parameters of the sql query
- $limit (int) the maximum number of rows
- $offset (int) from which row we want to start
Throws: \OCP\AppFramework\Db\DoesNotExistExceptionif the item does not existThrows: \OCP\AppFramework\Db\MultipleObjectsReturnedExceptionif more than one item existThrows: \OCP\AppFramework\Db\DoesNotExistExceptionif the item does not existThrows: \OCP\AppFramework\Db\MultipleObjectsReturnedExceptionif more than one item existReturns: \OCP\AppFramework\Db\Entitythe entitySince: 7.0.0
Deprecated: 14.0.0 Move over to QBMapper