Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
azielinski committed Mar 1, 2015
2 parents 95abec1 + d381bb7 commit 397f0ea
Show file tree
Hide file tree
Showing 30 changed files with 723 additions and 115 deletions.
14 changes: 7 additions & 7 deletions lib/Doctrine/DBAL/Cache/ArrayStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace Doctrine\DBAL\Cache;

use Doctrine\DBAL\Driver\ResultStatement;
use PDO;
use Doctrine\DBAL\PDOCompat;

class ArrayStatement implements \IteratorAggregate, ResultStatement
{
Expand All @@ -42,7 +42,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
/**
* @var integer
*/
private $defaultFetchMode = PDO::FETCH_BOTH;
private $defaultFetchMode = PDOCompat::FETCH_BOTH;

/**
* @param array $data
Expand Down Expand Up @@ -103,13 +103,13 @@ public function fetch($fetchMode = null)
if (isset($this->data[$this->num])) {
$row = $this->data[$this->num++];
$fetchMode = $fetchMode ?: $this->defaultFetchMode;
if ($fetchMode === PDO::FETCH_ASSOC) {
if ($fetchMode === PDOCompat::FETCH_ASSOC) {
return $row;
} elseif ($fetchMode === PDO::FETCH_NUM) {
} elseif ($fetchMode === PDOCompat::FETCH_NUM) {
return array_values($row);
} elseif ($fetchMode === PDO::FETCH_BOTH) {
} elseif ($fetchMode === PDOCompat::FETCH_BOTH) {
return array_merge($row, array_values($row));
} elseif ($fetchMode === PDO::FETCH_COLUMN) {
} elseif ($fetchMode === PDOCompat::FETCH_COLUMN) {
return reset($row);
} else {
throw new \InvalidArgumentException("Invalid fetch-style given for fetching result.");
Expand Down Expand Up @@ -137,7 +137,7 @@ public function fetchAll($fetchMode = null)
*/
public function fetchColumn($columnIndex = 0)
{
$row = $this->fetch(PDO::FETCH_NUM);
$row = $this->fetch(PDOCompat::FETCH_NUM);
if (!isset($row[$columnIndex])) {
// TODO: verify this is correct behavior
return false;
Expand Down
16 changes: 8 additions & 8 deletions lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\Common\Cache\Cache;
use PDO;
use Doctrine\DBAL\PDOCompat;

/**
* Cache statement for SQL results.
Expand Down Expand Up @@ -80,7 +80,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
/**
* @var integer
*/
private $defaultFetchMode = PDO::FETCH_BOTH;
private $defaultFetchMode = PDOCompat::FETCH_BOTH;

/**
* @param \Doctrine\DBAL\Driver\Statement $stmt
Expand Down Expand Up @@ -153,19 +153,19 @@ public function fetch($fetchMode = null)
$this->data = array();
}

$row = $this->statement->fetch(PDO::FETCH_ASSOC);
$row = $this->statement->fetch(PDOCompat::FETCH_ASSOC);
if ($row) {
$this->data[] = $row;

$fetchMode = $fetchMode ?: $this->defaultFetchMode;

if ($fetchMode == PDO::FETCH_ASSOC) {
if ($fetchMode == PDOCompat::FETCH_ASSOC) {
return $row;
} elseif ($fetchMode == PDO::FETCH_NUM) {
} elseif ($fetchMode == PDOCompat::FETCH_NUM) {
return array_values($row);
} elseif ($fetchMode == PDO::FETCH_BOTH) {
} elseif ($fetchMode == PDOCompat::FETCH_BOTH) {
return array_merge($row, array_values($row));
} elseif ($fetchMode == PDO::FETCH_COLUMN) {
} elseif ($fetchMode == PDOCompat::FETCH_COLUMN) {
return reset($row);
} else {
throw new \InvalidArgumentException("Invalid fetch-style given for caching result.");
Expand Down Expand Up @@ -194,7 +194,7 @@ public function fetchAll($fetchMode = null)
*/
public function fetchColumn($columnIndex = 0)
{
$row = $this->fetch(PDO::FETCH_NUM);
$row = $this->fetch(PDOCompat::FETCH_NUM);
if (!isset($row[$columnIndex])) {
// TODO: verify this is correct behavior
return false;
Expand Down
9 changes: 4 additions & 5 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use PDO;
use Closure;
use Exception;
use Doctrine\DBAL\Types\Type;
Expand Down Expand Up @@ -186,7 +185,7 @@ class Connection implements DriverConnection
/**
* @var integer
*/
protected $defaultFetchMode = PDO::FETCH_ASSOC;
protected $defaultFetchMode = PDOCompat::FETCH_ASSOC;

/**
* Initializes a new instance of the Connection class.
Expand Down Expand Up @@ -507,7 +506,7 @@ public function setFetchMode($fetchMode)
*/
public function fetchAssoc($statement, array $params = array(), array $types = array())
{
return $this->executeQuery($statement, $params, $types)->fetch(PDO::FETCH_ASSOC);
return $this->executeQuery($statement, $params, $types)->fetch(PDOCompat::FETCH_ASSOC);
}

/**
Expand All @@ -522,7 +521,7 @@ public function fetchAssoc($statement, array $params = array(), array $types = a
*/
public function fetchArray($statement, array $params = array(), array $types = array())
{
return $this->executeQuery($statement, $params, $types)->fetch(PDO::FETCH_NUM);
return $this->executeQuery($statement, $params, $types)->fetch(PDOCompat::FETCH_NUM);
}

/**
Expand Down Expand Up @@ -711,7 +710,7 @@ private function extractTypeValues(array $data, array $types)
foreach ($data as $k => $_) {
$typeValues[] = isset($types[$k])
? $types[$k]
: \PDO::PARAM_STR;
: PDOCompat::PARAM_STR;
}

return $typeValues;
Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/DBAL/Driver/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\PDOCompat;

/**
* Connection interface.
* Driver connections must implement this interface.
Expand Down Expand Up @@ -53,7 +55,7 @@ function query();
*
* @return string
*/
function quote($input, $type=\PDO::PARAM_STR);
function quote($input, $type=PDOCompat::PARAM_STR);

/**
* Executes an SQL statement and return the number of affected rows.
Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Doctrine\DBAL\Driver\IBMDB2;

use Doctrine\DBAL\PDOCompat;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;

Expand Down Expand Up @@ -98,10 +99,10 @@ public function query()
/**
* {@inheritdoc}
*/
public function quote($input, $type=\PDO::PARAM_STR)
public function quote($input, $type=PDOCompat::PARAM_STR)
{
$input = db2_escape_string($input);
if ($type == \PDO::PARAM_INT) {
if ($type == PDOCompat::PARAM_INT) {
return $input;
} else {
return "'".$input."'";
Expand Down
27 changes: 14 additions & 13 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace Doctrine\DBAL\Driver\IBMDB2;

use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\PDOCompat;

class DB2Statement implements \IteratorAggregate, Statement
{
Expand All @@ -34,28 +35,28 @@ class DB2Statement implements \IteratorAggregate, Statement
private $_bindParam = array();

/**
* @var string Name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
* @var string Name of the default class to instantiate when fetch mode is PDOCompat::FETCH_CLASS.
*/
private $defaultFetchClass = '\stdClass';

/**
* @var string Constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
* @var string Constructor arguments for the default class to instantiate when fetch mode is PDOCompat::FETCH_CLASS.
*/
private $defaultFetchClassCtorArgs = array();

/**
* @var integer
*/
private $_defaultFetchMode = \PDO::FETCH_BOTH;
private $_defaultFetchMode = PDOCompat::FETCH_BOTH;

/**
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
*
* @var array
*/
static private $_typeMap = array(
\PDO::PARAM_INT => DB2_LONG,
\PDO::PARAM_STR => DB2_CHAR,
PDOCompat::PARAM_INT => DB2_LONG,
PDOCompat::PARAM_STR => DB2_CHAR,
);

/**
Expand Down Expand Up @@ -199,11 +200,11 @@ public function fetch($fetchMode = null)
{
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
switch ($fetchMode) {
case \PDO::FETCH_BOTH:
case PDOCompat::FETCH_BOTH:
return db2_fetch_both($this->_stmt);
case \PDO::FETCH_ASSOC:
case PDOCompat::FETCH_ASSOC:
return db2_fetch_assoc($this->_stmt);
case \PDO::FETCH_CLASS:
case PDOCompat::FETCH_CLASS:
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;

Expand All @@ -220,9 +221,9 @@ public function fetch($fetchMode = null)
}

return $result;
case \PDO::FETCH_NUM:
case PDOCompat::FETCH_NUM:
return db2_fetch_array($this->_stmt);
case \PDO::FETCH_OBJ:
case PDOCompat::FETCH_OBJ:
return db2_fetch_object($this->_stmt);
default:
throw new DB2Exception("Given Fetch-Style " . $fetchMode . " is not supported.");
Expand All @@ -237,12 +238,12 @@ public function fetchAll($fetchMode = null)
$rows = array();

switch ($fetchMode) {
case \PDO::FETCH_CLASS:
case PDOCompat::FETCH_CLASS:
while ($row = call_user_func_array(array($this, 'fetch'), func_get_args())) {
$rows[] = $row;
}
break;
case \PDO::FETCH_COLUMN:
case PDOCompat::FETCH_COLUMN:
while ($row = $this->fetchColumn()) {
$rows[] = $row;
}
Expand All @@ -261,7 +262,7 @@ public function fetchAll($fetchMode = null)
*/
public function fetchColumn($columnIndex = 0)
{
$row = $this->fetch(\PDO::FETCH_NUM);
$row = $this->fetch(PDOCompat::FETCH_NUM);

if (false === $row) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Doctrine\DBAL\Driver\Connection as Connection;
use Doctrine\DBAL\Driver\PingableConnection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\PDOCompat;

/**
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
Expand Down Expand Up @@ -136,7 +137,7 @@ public function query()
/**
* {@inheritdoc}
*/
public function quote($input, $type=\PDO::PARAM_STR)
public function quote($input, $type=PDOCompat::PARAM_STR)
{
return "'". $this->_conn->escape_string($input) ."'";
}
Expand Down
26 changes: 13 additions & 13 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace Doctrine\DBAL\Driver\Mysqli;

use Doctrine\DBAL\Driver\Statement;
use PDO;
use Doctrine\DBAL\PDOCompat;

/**
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
Expand All @@ -31,11 +31,11 @@ class MysqliStatement implements \IteratorAggregate, Statement
* @var array
*/
protected static $_paramTypeMap = array(
PDO::PARAM_STR => 's',
PDO::PARAM_BOOL => 'i',
PDO::PARAM_NULL => 's',
PDO::PARAM_INT => 'i',
PDO::PARAM_LOB => 's' // TODO Support LOB bigger then max package size.
PDOCompat::PARAM_STR => 's',
PDOCompat::PARAM_BOOL => 'i',
PDOCompat::PARAM_NULL => 's',
PDOCompat::PARAM_INT => 'i',
PDOCompat::PARAM_LOB => 's' // TODO Support LOB bigger then max package size.
);

/**
Expand Down Expand Up @@ -78,7 +78,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
/**
* @var integer
*/
protected $_defaultFetchMode = PDO::FETCH_BOTH;
protected $_defaultFetchMode = PDOCompat::FETCH_BOTH;

/**
* @param \mysqli $conn
Expand Down Expand Up @@ -252,19 +252,19 @@ public function fetch($fetchMode = null)
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;

switch ($fetchMode) {
case PDO::FETCH_NUM:
case PDOCompat::FETCH_NUM:
return $values;

case PDO::FETCH_ASSOC:
case PDOCompat::FETCH_ASSOC:
return array_combine($this->_columnNames, $values);

case PDO::FETCH_BOTH:
case PDOCompat::FETCH_BOTH:
$ret = array_combine($this->_columnNames, $values);
$ret += $values;

return $ret;

case PDO::FETCH_OBJ:
case PDOCompat::FETCH_OBJ:
$assoc = array_combine($this->_columnNames, $values);
$ret = new \stdClass();

Expand All @@ -287,7 +287,7 @@ public function fetchAll($fetchMode = null)
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;

$rows = array();
if (PDO::FETCH_COLUMN == $fetchMode) {
if (PDOCompat::FETCH_COLUMN == $fetchMode) {
while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row;
}
Expand All @@ -305,7 +305,7 @@ public function fetchAll($fetchMode = null)
*/
public function fetchColumn($columnIndex = 0)
{
$row = $this->fetch(PDO::FETCH_NUM);
$row = $this->fetch(PDOCompat::FETCH_NUM);
if (null === $row) {
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Doctrine\DBAL\Driver\OCI8;

use Doctrine\DBAL\PDOCompat;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Platforms\OraclePlatform;
Expand Down Expand Up @@ -121,7 +122,7 @@ public function query()
/**
* {@inheritdoc}
*/
public function quote($value, $type=\PDO::PARAM_STR)
public function quote($value, $type=PDOCompat::PARAM_STR)
{
if (is_int($value) || is_float($value)) {
return $value;
Expand Down Expand Up @@ -155,7 +156,7 @@ public function lastInsertId($name = null)

$sql = 'SELECT ' . $name . '.CURRVAL FROM DUAL';
$stmt = $this->query($sql);
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
$result = $stmt->fetch(PDOCompat::FETCH_ASSOC);

if ($result === false || !isset($result['CURRVAL'])) {
throw new OCI8Exception("lastInsertId failed: Query was executed but no result was returned.");
Expand Down
Loading

0 comments on commit 397f0ea

Please sign in to comment.