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

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

ralphschindler
Copy link
Member

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

* Select Joins should share state when processing subselect
* Decorators should be propagated down into subselects
@ralphschindler
Copy link
Member

Can you try the attached PR for me?

@ralphschindler ralphschindler added this to the 2.3.1 milestone Mar 12, 2014
@ralphschindler ralphschindler self-assigned this Mar 12, 2014
@nicklevett
Copy link
Author

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

Thanks!

weierophinney added a commit that referenced this pull request Apr 11, 2014
…joins-sharing-process-state

Zend Db: Multiple nested selects - Zend Paginator with nested select bind parameters error
weierophinney added a commit that referenced this pull request Apr 11, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants