ignore cursorclosing
This commit is contained in:
parent
55142186de
commit
37e8969d34
|
@ -69,6 +69,7 @@ class OC_DB_StatementWrapper {
|
|||
return false;
|
||||
}
|
||||
if ($this->isManipulation) {
|
||||
$this->statement->closeCursor();
|
||||
return $this->statement->rowCount();
|
||||
} else {
|
||||
return $this;
|
||||
|
|
|
@ -70,10 +70,12 @@ abstract class Mapper {
|
|||
/**
|
||||
* Deletes an entity from the table
|
||||
* @param Entity $entity the entity that should be deleted
|
||||
* @return Entity the deleted entity
|
||||
*/
|
||||
public function delete(Entity $entity){
|
||||
$sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?';
|
||||
$this->execute($sql, array($entity->getId()));
|
||||
$this->execute($sql, [$entity->getId()]);
|
||||
return $entity;
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,7 +90,7 @@ abstract class Mapper {
|
|||
$properties = $entity->getUpdatedFields();
|
||||
$values = '';
|
||||
$columns = '';
|
||||
$params = array();
|
||||
$params = [];
|
||||
|
||||
// build the fields
|
||||
$i = 0;
|
||||
|
@ -116,6 +118,7 @@ abstract class Mapper {
|
|||
$this->execute($sql, $params);
|
||||
|
||||
$entity->setId((int) $this->db->getInsertId($this->tableName));
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
|
@ -147,7 +150,7 @@ abstract class Mapper {
|
|||
unset($properties['id']);
|
||||
|
||||
$columns = '';
|
||||
$params = array();
|
||||
$params = [];
|
||||
|
||||
// build the fields
|
||||
$i = 0;
|
||||
|
@ -185,7 +188,7 @@ abstract class Mapper {
|
|||
* @param int $offset from which row we want to start
|
||||
* @return \PDOStatement the database query result
|
||||
*/
|
||||
protected function execute($sql, array $params=array(), $limit=null, $offset=null){
|
||||
protected function execute($sql, array $params=[], $limit=null, $offset=null){
|
||||
$query = $this->db->prepareQuery($sql, $limit, $offset);
|
||||
|
||||
$index = 1; // bindParam is 1 indexed
|
||||
|
@ -226,14 +229,16 @@ abstract class Mapper {
|
|||
* @throws MultipleObjectsReturnedException if more than one item exist
|
||||
* @return array the result as row
|
||||
*/
|
||||
protected function findOneQuery($sql, array $params=array(), $limit=null, $offset=null){
|
||||
$result = $this->execute($sql, $params, $limit, $offset);
|
||||
$row = $result->fetch();
|
||||
protected function findOneQuery($sql, array $params=[], $limit=null, $offset=null){
|
||||
$stmt = $this->execute($sql, $params, $limit, $offset);
|
||||
$row = $stmt->fetch();
|
||||
|
||||
if($row === false || $row === null){
|
||||
$stmt->closeCursor();
|
||||
throw new DoesNotExistException('No matching entry found');
|
||||
}
|
||||
$row2 = $result->fetch();
|
||||
$row2 = $stmt->fetch();
|
||||
$stmt->closeCursor();
|
||||
//MDB2 returns null, PDO and doctrine false when no row is available
|
||||
if( ! ($row2 === false || $row2 === null )) {
|
||||
throw new MultipleObjectsReturnedException('More than one result');
|
||||
|
@ -262,15 +267,17 @@ abstract class Mapper {
|
|||
* @param int $offset from which row we want to start
|
||||
* @return array all fetched entities
|
||||
*/
|
||||
protected function findEntities($sql, array $params=array(), $limit=null, $offset=null) {
|
||||
$result = $this->execute($sql, $params, $limit, $offset);
|
||||
protected function findEntities($sql, array $params=[], $limit=null, $offset=null) {
|
||||
$stmt = $this->execute($sql, $params, $limit, $offset);
|
||||
|
||||
$entities = array();
|
||||
$entities = [];
|
||||
|
||||
while($row = $result->fetch()){
|
||||
while($row = $stmt->fetch()){
|
||||
$entities[] = $this->mapRowToEntity($row);
|
||||
}
|
||||
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $entities;
|
||||
}
|
||||
|
||||
|
@ -286,7 +293,7 @@ abstract class Mapper {
|
|||
* @throws MultipleObjectsReturnedException if more than one item exist
|
||||
* @return Entity the entity
|
||||
*/
|
||||
protected function findEntity($sql, array $params=array(), $limit=null, $offset=null){
|
||||
protected function findEntity($sql, array $params=[], $limit=null, $offset=null){
|
||||
return $this->mapRowToEntity($this->findOneQuery($sql, $params, $limit, $offset));
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ abstract class MapperTestUtility extends \Test\TestCase {
|
|||
->getMock();
|
||||
|
||||
$this->query = $this->getMock('Query', array('execute', 'bindValue'));
|
||||
$this->pdoResult = $this->getMock('Result', array('fetch'));
|
||||
$this->pdoResult = $this->getMock('Result', array('fetch', 'closeCursor'));
|
||||
$this->queryAt = 0;
|
||||
$this->prepareAt = 0;
|
||||
$this->iterators = array();
|
||||
|
@ -90,7 +90,8 @@ abstract class MapperTestUtility extends \Test\TestCase {
|
|||
return $result;
|
||||
}
|
||||
));
|
||||
|
||||
$this->pdoResult->expects($this->any())
|
||||
->method('closeCursor');
|
||||
$index = 1;
|
||||
foreach($arguments as $argument) {
|
||||
switch (gettype($argument)) {
|
||||
|
|
Loading…
Reference in New Issue