diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-02-24 16:39:25 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-25 22:21:24 +0100 |
commit | fb84e7d2823d0fe8ff8b20048eb6bae37e377d7c (patch) | |
tree | 65d1d2caf65957931a5a30c6b19057b48589ec2f /lib/public/appframework/db/mapper.php | |
parent | 0720cf0ad1f7ed0536038d059a8ac6c073265237 (diff) | |
download | nextcloud-server-fb84e7d2823d0fe8ff8b20048eb6bae37e377d7c.tar.gz nextcloud-server-fb84e7d2823d0fe8ff8b20048eb6bae37e377d7c.zip |
migrate to IDBConnection
Diffstat (limited to 'lib/public/appframework/db/mapper.php')
-rw-r--r-- | lib/public/appframework/db/mapper.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/public/appframework/db/mapper.php b/lib/public/appframework/db/mapper.php index 0edc38ade54..2022c7bfc88 100644 --- a/lib/public/appframework/db/mapper.php +++ b/lib/public/appframework/db/mapper.php @@ -22,7 +22,7 @@ */ namespace OCP\AppFramework\Db; -use \OCP\IDb; +use \OCP\IDBConnection; /** @@ -36,12 +36,12 @@ abstract class Mapper { protected $db; /** - * @param IDb $db Instance of the Db abstraction layer + * @param IDBConnection $db Instance of the Db abstraction layer * @param string $tableName the name of the table. set this to allow entity * @param string $entityClass the name of the entity that the sql should be * mapped to queries without using sql */ - public function __construct(IDb $db, $tableName, $entityClass=null){ + public function __construct(IDBConnection $db, $tableName, $entityClass=null){ $this->db = $db; $this->tableName = '*PREFIX*' . $tableName; @@ -113,7 +113,7 @@ abstract class Mapper { $this->execute($sql, $params); - $entity->setId((int) $this->db->getInsertId($this->tableName)); + $entity->setId((int) $this->db->lastInsertId($this->tableName)); return $entity; } @@ -185,7 +185,7 @@ abstract class Mapper { * @return \PDOStatement the database query result */ protected function execute($sql, array $params=[], $limit=null, $offset=null){ - $query = $this->db->prepareQuery($sql, $limit, $offset); + $query = $this->db->prepare($sql, $limit, $offset); $index = 1; // bindParam is 1 indexed foreach($params as $param) { @@ -209,7 +209,9 @@ abstract class Mapper { $index++; } - return $query->execute(); + $query->execute(); + + return $query; } |