summaryrefslogtreecommitdiffstats
path: root/lib/public/appframework
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-02-24 16:47:38 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-02-25 22:21:24 +0100
commit7b2fdbfb0b7b97c97501af79cfa0cb34be333c02 (patch)
treeed991e209c068360975666d232ac5d937b323f29 /lib/public/appframework
parentfb84e7d2823d0fe8ff8b20048eb6bae37e377d7c (diff)
downloadnextcloud-server-7b2fdbfb0b7b97c97501af79cfa0cb34be333c02.tar.gz
nextcloud-server-7b2fdbfb0b7b97c97501af79cfa0cb34be333c02.zip
use IDBConnection and close cursors after insert/update/delete
Diffstat (limited to 'lib/public/appframework')
-rw-r--r--lib/public/appframework/db/mapper.php16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/public/appframework/db/mapper.php b/lib/public/appframework/db/mapper.php
index 2022c7bfc88..4424ef3622b 100644
--- a/lib/public/appframework/db/mapper.php
+++ b/lib/public/appframework/db/mapper.php
@@ -70,7 +70,8 @@ abstract class Mapper {
*/
public function delete(Entity $entity){
$sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?';
- $this->execute($sql, [$entity->getId()]);
+ $stmt = $this->execute($sql, [$entity->getId()]);
+ $stmt->closeCursor();
return $entity;
}
@@ -103,7 +104,7 @@ abstract class Mapper {
$values .= ',';
}
- array_push($params, $entity->$getter());
+ $params[] = $entity->$getter();
$i++;
}
@@ -111,10 +112,12 @@ abstract class Mapper {
$sql = 'INSERT INTO `' . $this->tableName . '`(' .
$columns . ') VALUES(' . $values . ')';
- $this->execute($sql, $params);
+ $stmt = $this->execute($sql, $params);
$entity->setId((int) $this->db->lastInsertId($this->tableName));
+ $stmt->closeCursor();
+
return $entity;
}
@@ -162,15 +165,16 @@ abstract class Mapper {
$columns .= ',';
}
- array_push($params, $entity->$getter());
+ $params[] = $entity->$getter();
$i++;
}
$sql = 'UPDATE `' . $this->tableName . '` SET ' .
$columns . ' WHERE `id` = ?';
- array_push($params, $id);
+ $params[] = $id;
- $this->execute($sql, $params);
+ $stmt = $this->execute($sql, $params);
+ $stmt->closeCursor();
return $entity;
}