Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge PR #3988 to master

  • Loading branch information...
commit 379d16f3c83dddd4b29acf5ad165d29b1852329d 2 parents 087f459 + 466d501
@ralphschindler ralphschindler authored
View
8 library/Zend/Db/Sql/Insert.php
@@ -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);
+ }
}
}
View
15 tests/ZendTest/Db/Sql/SqlTest.php
@@ -16,6 +16,11 @@ class TableGatewayTest extends \PHPUnit_Framework_TestCase
{
protected $mockAdapter = null;
+
+ /**
+ * Sql object
+ * @var 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);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.