replace fetchRow with fetch to honour pdostatement

This commit is contained in:
Bernhard Posselt 2014-05-12 23:21:01 +02:00
Родитель 874c469e02
Коммит 2dd8827768
4 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -80,7 +80,7 @@ class ItemMapper extends Mapper implements IMapper {
$params = array($userId); $params = array($userId);
$result = $this->execute($sql, $params)->fetchRow(); $result = $this->execute($sql, $params)->fetch();
return (int) $result['size']; return (int) $result['size'];
} }
@ -230,7 +230,7 @@ class ItemMapper extends Mapper implements IMapper {
$params = array($status, $threshold); $params = array($status, $threshold);
$result = $this->execute($sql, $params); $result = $this->execute($sql, $params);
while($row = $result->fetchRow()) { while($row = $result->fetch()) {
$size = (int) $row['size']; $size = (int) $row['size'];
$limit = $size - $threshold; $limit = $size - $threshold;

Просмотреть файл

@ -207,12 +207,12 @@ abstract class Mapper {
*/ */
protected function findOneQuery($sql, array $params=array(), $limit=null, $offset=null){ protected function findOneQuery($sql, array $params=array(), $limit=null, $offset=null){
$result = $this->execute($sql, $params, $limit, $offset); $result = $this->execute($sql, $params, $limit, $offset);
$row = $result->fetchRow(); $row = $result->fetch();
if($row === false || $row === null){ if($row === false || $row === null){
throw new DoesNotExistException('No matching entry found'); throw new DoesNotExistException('No matching entry found');
} }
$row2 = $result->fetchRow(); $row2 = $result->fetch();
//MDB2 returns null, PDO and doctrine false when no row is available //MDB2 returns null, PDO and doctrine false when no row is available
if( ! ($row2 === false || $row2 === null )) { if( ! ($row2 === false || $row2 === null )) {
throw new MultipleObjectsReturnedException('More than one result'); throw new MultipleObjectsReturnedException('More than one result');
@ -246,7 +246,7 @@ abstract class Mapper {
$entities = array(); $entities = array();
while($row = $result->fetchRow()){ while($row = $result->fetch()){
$entities[] = $this->mapRowToEntity($row); $entities[] = $this->mapRowToEntity($row);
} }

Просмотреть файл

@ -44,7 +44,7 @@ class ItemMapper extends \OCA\News\Db\ItemMapper {
$params = array($status, $threshold); $params = array($status, $threshold);
$result = $this->execute($sql, $params); $result = $this->execute($sql, $params);
while($row = $result->fetchRow()) { while($row = $result->fetch()) {
$size = (int) $row['size']; $size = (int) $row['size'];
$limit = $size - $threshold; $limit = $size - $threshold;

Просмотреть файл

@ -42,7 +42,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase {
->getMock(); ->getMock();
$this->query = $this->getMock('Query', array('execute', 'bindValue')); $this->query = $this->getMock('Query', array('execute', 'bindValue'));
$this->pdoResult = $this->getMock('Result', array('fetchRow')); $this->pdoResult = $this->getMock('Result', array('fetch'));
$this->queryAt = 0; $this->queryAt = 0;
$this->prepareAt = 0; $this->prepareAt = 0;
$this->iterators = array(); $this->iterators = array();
@ -68,7 +68,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase {
$fetchAt = $this->fetchAt; $fetchAt = $this->fetchAt;
$this->pdoResult->expects($this->any()) $this->pdoResult->expects($this->any())
->method('fetchRow') ->method('fetch')
->will($this->returnCallback( ->will($this->returnCallback(
function() use ($iterators, $fetchAt){ function() use ($iterators, $fetchAt){
$iterator = $iterators[$fetchAt]; $iterator = $iterators[$fetchAt];