diff --git a/lib/public/appframework/db/mapper.php b/lib/public/appframework/db/mapper.php index 5143547c8e..aaef0f79d2 100644 --- a/lib/public/appframework/db/mapper.php +++ b/lib/public/appframework/db/mapper.php @@ -26,7 +26,8 @@ namespace OCP\AppFramework\Db; -use \OCP\IDBConnection; +use OCP\IDBConnection; +use OCP\IDb; /** @@ -193,7 +194,11 @@ abstract class Mapper { * @return \PDOStatement the database query result */ protected function execute($sql, array $params=[], $limit=null, $offset=null){ - $query = $this->db->prepare($sql, $limit, $offset); + if ($this->db instanceof IDb) { + $query = $this->db->prepareQuery($sql, $limit, $offset); + } else { + $query = $this->db->prepare($sql, $limit, $offset); + } $index = 1; // bindParam is 1 indexed foreach($params as $param) { @@ -217,7 +222,16 @@ abstract class Mapper { $index++; } - $query->execute(); + $result = $query->execute(); + + // this is only for backwards compatibility reasons and can be removed + // in owncloud 10. IDb returns a StatementWrapper from execute, PDO, + // Doctrine and IDbConnection don't so this needs to be done in order + // to stay backwards compatible for the things that rely on the + // StatementWrapper being returned + if ($result instanceof \OC_DB_StatementWrapper) { + return $result; + } return $query; }