Commit 5f4d92a1 authored by Steve Müller's avatar Steve Müller Committed by GitHub

Merge pull request #2443 from chrisguitarguy/fix_2440

Track the Values & Types Passed to Statement::bindParam
parents 17f50b86 2442c2b5
......@@ -138,6 +138,9 @@ class Statement implements \IteratorAggregate, DriverStatement
*/
public function bindParam($name, &$var, $type = PDO::PARAM_STR, $length = null)
{
$this->params[$name] = $var;
$this->types[$name] = $type;
return $this->stmt->bindParam($name, $var, $type, $length);
}
......
......@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL;
use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Logging\SQLLogger;
class StatementTest extends \Doctrine\Tests\DbalTestCase
{
......@@ -103,6 +104,28 @@ class StatementTest extends \Doctrine\Tests\DbalTestCase
$statement->execute($values);
}
public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam()
{
$name = 'foo';
$var = 'bar';
$values = [$name => $var];
$types = [$name => \PDO::PARAM_STR];
$sql = '';
$logger = $this->createMock(SQLLogger::class);
$logger->expects(self::once())
->method('startQuery')
->with(self::equalTo($sql), self::equalTo($values), self::equalTo($types));
$this->configuration->expects(self::once())
->method('getSQLLogger')
->willReturn($logger);
$statement = new Statement($sql, $this->conn);
$statement->bindParam($name, $var);
$statement->execute();
}
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
......
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