Unverified Commit a5326972 authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub

Merge pull request #2964 from morozov/issues/2963

Implemented Statement::fetch(PDO::FETCH_COLUMN) in non-PDO driveres
parents 8575c255 bc238319
......@@ -216,6 +216,9 @@ class DB2Statement implements \IteratorAggregate, Statement
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
switch ($fetchMode) {
case \PDO::FETCH_COLUMN:
return $this->fetchColumn();
case \PDO::FETCH_BOTH:
return db2_fetch_both($this->_stmt);
case \PDO::FETCH_ASSOC:
......
......@@ -272,6 +272,12 @@ class MysqliStatement implements \IteratorAggregate, Statement
return false;
}
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
if ($fetchMode === PDO::FETCH_COLUMN) {
return $this->fetchColumn();
}
$values = $this->_fetch();
if (null === $values) {
return false;
......@@ -281,8 +287,6 @@ class MysqliStatement implements \IteratorAggregate, Statement
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
}
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
switch ($fetchMode) {
case PDO::FETCH_NUM:
return $values;
......
......@@ -387,6 +387,10 @@ class OCI8Statement implements IteratorAggregate, Statement
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
if ($fetchMode === PDO::FETCH_COLUMN) {
return $this->fetchColumn();
}
if (PDO::FETCH_OBJ == $fetchMode) {
return oci_fetch_object($this->_sth);
}
......
......@@ -203,6 +203,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
$fetchMode = $fetchMode ?: $this->defaultFetchMode;
switch ($fetchMode) {
case PDO::FETCH_COLUMN:
return $this->fetchColumn();
case PDO::FETCH_ASSOC:
return sasql_fetch_assoc($this->result);
case PDO::FETCH_BOTH:
......
......@@ -315,6 +315,10 @@ class SQLSrvStatement implements IteratorAggregate, Statement
$args = func_get_args();
$fetchMode = $fetchMode ?: $this->defaultFetchMode;
if ($fetchMode === PDO::FETCH_COLUMN) {
return $this->fetchColumn();
}
if (isset(self::$fetchMap[$fetchMode])) {
return sqlsrv_fetch_array($this->stmt, self::$fetchMap[$fetchMode]) ?: false;
}
......
......@@ -282,4 +282,13 @@ EOF
),
);
}
public function testFetchInColumnMode() : void
{
$platform = $this->_conn->getDatabasePlatform();
$query = $platform->getDummySelectSQL();
$result = $this->_conn->executeQuery($query)->fetch(\PDO::FETCH_COLUMN);
self::assertEquals(1, $result);
}
}
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