Merge pull request #14986 from owncloud/fixmapperbackw

Fix backwards compatibility for mapper execute method
This commit is contained in:
Thomas Müller 2015-03-19 17:04:01 +01:00
commit 3765af4edf
1 changed files with 17 additions and 3 deletions

View File

@ -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;
}