diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-08-16 15:37:39 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-08-16 15:37:39 +0300 |
commit | 02dd95d10de041278d8bc05f7f548e44471db60b (patch) | |
tree | 53fe3c41a85cacb7794179460815cb2f29571ffb /lib | |
parent | 22f15363c29f1ee7227d6aab219f8e6fad932ff7 (diff) |
Migrate the LocalAttachmentsMapper to the QBMapper
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Db/LocalAttachmentMapper.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/Db/LocalAttachmentMapper.php b/lib/Db/LocalAttachmentMapper.php index c4c932b8f..bd98e14bf 100644 --- a/lib/Db/LocalAttachmentMapper.php +++ b/lib/Db/LocalAttachmentMapper.php @@ -23,10 +23,10 @@ namespace OCA\Mail\Db; use OCP\AppFramework\Db\DoesNotExistException; -use OCP\AppFramework\Db\Mapper; +use OCP\AppFramework\Db\QBMapper; use OCP\IDBConnection; -class LocalAttachmentMapper extends Mapper { +class LocalAttachmentMapper extends QBMapper { /** * @param IDBConnection $db @@ -37,15 +37,20 @@ class LocalAttachmentMapper extends Mapper { /** * @throws DoesNotExistException + * * @param int $userId * @param int $id + * * @return LocalAttachment */ public function find($userId, $id) { - $sql = 'SELECT * FROM `' . $this->getTableName() . '` WHERE user_id = ? and id = ?'; - $params = [$userId, $id]; + $qb = $this->db->getQueryBuilder(); + $query = $qb + ->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); - return $this->findEntity($sql, $params); + return $this->findEntity($query); } } |