Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix' of https://github.com/ramonornela/zf2 into hotf…
Browse files Browse the repository at this point in the history
…ix/zf-10704
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Adapter/DbSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ public function getCountSelect()
*/
if (!empty($unionParts)) {
$expression = new Db\Expr($countPart . $countColumn);

$rowCount = $db->select()->from($rowCount, $expression);
$rowCount = $db
->select()
->bind($rowCount->getBind())
->from($rowCount, $expression);
} else {
$columnParts = $rowCount->getPart(Select::COLUMNS);
$groupParts = $rowCount->getPart(Select::GROUP);
Expand Down
30 changes: 29 additions & 1 deletion test/Adapter/DbSelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testThrowsExceptionIfInvalidQuerySuppliedForRowCount()
$this->setExpectedException('Zend\Paginator\Adapter\Exception\InvalidArgumentException', 'Row count column not found');
$this->_adapter->setRowCount($this->_db->select()->from('test'));
}

public function testThrowsExceptionIfInvalidQuerySuppliedForRowCount2()
{
$wrongcolumn = $this->_db->quoteIdentifier('wrongcolumn');
Expand Down Expand Up @@ -454,4 +454,32 @@ public function testMultipleGroupSelect()
$this->assertEquals($expected, $adapter->getCountSelect()->__toString());
$this->assertEquals(250, $adapter->count());
}

/**
* @group ZF-10704
*/
public function testObjectSelectWithBind()
{
$select = $this->_db->select();
$select->from('test', array('number'))
->where('number = ?')
->distinct(true)
->bind(array(250));

$adapter = new Adapter\DbSelect($select);
$this->assertEquals(1, $adapter->count());

$select->reset(\Zend\Db\Select::DISTINCT);
$select2 = clone $select;
$select2->reset(\Zend\Db\Select::WHERE)
->where('number = 500');

$selectUnion = $this->_db
->select()
->bind(array(250));

$selectUnion->union(array($select, $select2));
$adapter = new Adapter\DbSelect($selectUnion);
$this->assertEquals(2, $adapter->count());
}
}
Binary file modified test/_files/test.sqlite
Binary file not shown.

0 comments on commit 84a5bf6

Please sign in to comment.