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

Zend Db: Multiple nested selects - Zend Paginator with nested select bind parameters error #5392

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

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

@ralphschindler ralphschindler Zend\Db\Sql Select Subselect Bugfixes:
* Select Joins should share state when processing subselect
* Decorators should be propagated down into subselects
a890020
Member

ralphschindler commented Mar 12, 2014

Can you try the attached PR for me?

@ralphschindler ralphschindler added the Db label Mar 12, 2014

@ralphschindler ralphschindler added this to the 2.3.1 milestone Mar 12, 2014

@ralphschindler ralphschindler self-assigned this Mar 12, 2014

I've tested your PR, everything is now working.

Thanks!

@weierophinney weierophinney added a commit that referenced this pull request Apr 11, 2014

@weierophinney weierophinney Merge pull request #5392 from ralphschindler/hotfix/db-subselect-for-…
…joins-sharing-process-state

Zend Db: Multiple nested selects - Zend Paginator with nested select bind parameters error
4cdb133

@weierophinney weierophinney added a commit that referenced this pull request Apr 11, 2014

@weierophinney weierophinney Merge branch 'hotfix/5392' into develop
Forward port #5392
3af71d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment