zendframework/zf2 — pull request #5392 by ralphschindler (2014-03-12 17:42:56+00:00)
Title: Zend Db: Multiple nested selects - Zend Paginator with nested select bind parameters error

Using 2.2.4 with mysqli.

Zend\Db\Sql\AbstractSql->processSubSelect

This method keeps track of the number of subselects and so parameter keys do not get overwritten. However when using the Zend Paginator you get a:

Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement

The code to replicate this is at https://gist.github.com/nicklevett/7253154.

This what is produced by Zend\Db\Adapter\ParameterContainer->merge:
```
array(6) {
'subselect1where1' =>
string(4) "%AB%"
'subselect1where2' =>
int(4)
'subselect1where3' =>
int(1)
'subselect1where4' =>
int(2)
'subselect1where5' =>
int(1)
'subselect1where6' =>
bool(true)
}
```
But should be:
```
array(6) {
'subselect1where1' =>
int(1)
'subselect1where2' =>
int(4)
'subselect1where3' =>
int(1)
'subselect1where4' =>
int(2)
'subselect1where5' =>
int(1)
'subselect1where6' =>
bool(true)
'subselect2where1' =>
string(4) "%AB%"
}
```
The subselect is not incremented so subselect1where1 gets overwritten