Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/public/AppFramework/Db/QBMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ public function getTableName(): string {
return $this->tableName;
}

/**
* Locate one row by its primary key and throw when nothing is found
*
* @param IQueryBuilder $query
* @return Entity the result
* @psalm-return T the result
* @throws DoesNotExistException if the item does not exist
*
* @since 25.0.0
*/
public function findById(int $id): Entity {
$qb = $this->db->getQueryBuilder();
$select = $qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)
);
return $this->findEntity($select);
}


/**
* Deletes an entity from the table
Expand Down