Commit 208dd75f authored by Kim Hemsø Rasmussen's avatar Kim Hemsø Rasmussen

More of Stof's comments.

parent 88d16346
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......
...@@ -19,12 +19,13 @@ ...@@ -19,12 +19,13 @@
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\Statement;
use PDO; use PDO;
/** /**
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com> * @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/ */
class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement class MysqliStatement implements \IteratorAggregate, Statement
{ {
private static $_paramTypeMap = array( private static $_paramTypeMap = array(
PDO::PARAM_STR => 's', PDO::PARAM_STR => 's',
...@@ -220,14 +221,15 @@ class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\State ...@@ -220,14 +221,15 @@ class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\State
$values = $this->_fetch(); $values = $this->_fetch();
if (null === $values) { if (null === $values) {
return null; return null;
} elseif (false === $values) { }
if (false === $values) {
throw new MysqliException($this->_stmt->error, $this->_stmt->errno); throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
} }
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle; $fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle;
switch ($fetchStyle) switch ($fetchStyle) {
{
case PDO::FETCH_NUM: case PDO::FETCH_NUM:
return $values; return $values;
...@@ -247,7 +249,7 @@ class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\State ...@@ -247,7 +249,7 @@ class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\State
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchAll($fetchStyle = \PDO::FETCH_BOTH) public function fetchAll($fetchStyle = null)
{ {
$a = array(); $a = array();
while (($row = $this->fetch($fetchStyle)) !== null) { while (($row = $this->fetch($fetchStyle)) !== null) {
...@@ -261,13 +263,11 @@ class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\State ...@@ -261,13 +263,11 @@ class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\State
*/ */
public function fetchColumn($columnIndex = 0) public function fetchColumn($columnIndex = 0)
{ {
$values = $this->_fetch(); $row = $this->fetch(PDO::FETCH_NUM);
if (null === $values) { if (null === $row) {
return null; return null;
} elseif (false === $values) {
throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
} }
return $values[$columnIndex]; return $row[$columnIndex];
} }
/** /**
...@@ -300,7 +300,7 @@ class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\State ...@@ -300,7 +300,7 @@ class MysqliStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\State
*/ */
public function rowCount() public function rowCount()
{ {
if(false === $this->_columnNames) { if (false === $this->_columnNames) {
return $this->_stmt->affected_rows; return $this->_stmt->affected_rows;
} }
return $this->_stmt->num_rows; return $this->_stmt->num_rows;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment