Commit d057f6b0 authored by Benjamin Eberlei's avatar Benjamin Eberlei

DBAL-80 - Bugfix in Connection::_bindTypedValues().

parent e97fbbf7
...@@ -1007,7 +1007,7 @@ class Connection implements DriverConnection ...@@ -1007,7 +1007,7 @@ class Connection implements DriverConnection
// Check whether parameters are positional or named. Mixing is not allowed, just like in PDO. // Check whether parameters are positional or named. Mixing is not allowed, just like in PDO.
if (is_int(key($params))) { if (is_int(key($params))) {
// Positional parameters // Positional parameters
$typeOffset = isset($types[0]) ? -1 : 0; $typeOffset = array_key_exists(0, $types) ? -1 : 0;
$bindIndex = 1; $bindIndex = 1;
foreach ($params as $position => $value) { foreach ($params as $position => $value) {
$typeIndex = $bindIndex + $typeOffset; $typeIndex = $bindIndex + $typeOffset;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional; namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use PDO;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
...@@ -25,6 +26,18 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -25,6 +26,18 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->_conn->executeUpdate('DELETE FROM write_table'); $this->_conn->executeUpdate('DELETE FROM write_table');
} }
/**
* @group DBAL-80
*/
public function testExecuteUpdateFirstTypeIsNull()
{
$sql = "INSERT INTO write_table (test_string, test_int) VALUES (?, ?)";
$this->_conn->executeUpdate($sql, array("text", 1111), array(null, PDO::PARAM_INT));
$sql = "SELECT * FROM write_table WHERE test_string = ? AND test_int = ?";
$this->assertTrue((bool)$this->_conn->fetchColumn($sql, array("text", 1111)));
}
public function testExecuteUpdate() public function testExecuteUpdate()
{ {
$sql = "INSERT INTO write_table (test_int) VALUES ( " . $this->_conn->quote(1) . ")"; $sql = "INSERT INTO write_table (test_int) VALUES ( " . $this->_conn->quote(1) . ")";
......
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