Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix & Unit test for preparestatement notices #3988

Merged
merged 3 commits into from Mar 13, 2013
Jump to file or symbol
Failed to load files and symbols.
+21 −2
Split
@@ -168,13 +168,17 @@ public function prepareStatement(AdapterInterface $adapter, StatementContainerIn
foreach ($this->columns as $cIndex => $column) {
$columns[$cIndex] = $platform->quoteIdentifier($column);
- if ($this->values[$cIndex] instanceof Expression) {
+ if (isset($this->values[$cIndex]) && $this->values[$cIndex] instanceof Expression) {
$exprData = $this->processExpression($this->values[$cIndex], $platform, $driver);
$values[$cIndex] = $exprData->getSql();
$parameterContainer->merge($exprData->getParameterContainer());
} else {
$values[$cIndex] = $driver->formatParameterName($column);
- $parameterContainer->offsetSet($column, $this->values[$cIndex]);
+ if(isset($this->values[$cIndex])) {
+ $parameterContainer->offsetSet($column, $this->values[$cIndex]);
+ } else {
+ $parameterContainer->offsetSet($column, null);
+ }
}
}
@@ -16,6 +16,11 @@ class TableGatewayTest extends \PHPUnit_Framework_TestCase
{
protected $mockAdapter = null;
+
+ /**
+ * Sql object
+ * @var Zend\Db\Sql\Sql
+ */
protected $sql = null;
public function setup()
@@ -110,4 +115,14 @@ public function testDelete()
$this->sql->delete('bar');
}
+
+ /**
+ * @covers Zend\Db\Sql\Sql::prepareStatementForSqlObject
+ */
+ public function testprepareStatementForSqlObject()
+ {
+ $insert = $this->sql->insert()->columns(array('foo'));
+ $stmt = $this->sql->prepareStatementForSqlObject($insert);
+ $this->assertInstanceOf('Zend\Db\Adapter\Driver\StatementInterface', $stmt);
+ }
}