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

MySQL SelectDecorator - subselect limit parameter not prefixed (fix included) #318

Open
2 tasks done
smartwebproducts opened this issue May 16, 2018 · 2 comments
Open
2 tasks done

Comments

@smartwebproducts
Copy link

smartwebproducts commented May 16, 2018

When you have a FROM clause that includes a query with a LIMIT in it, and you try to prepare the query, you get following error:

Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php:239
Stack trace:
#0 vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php(239): PDOStatement->execute()

The reason for this is because the parameter name for the subselect's limit is :limit while in the parameterContainer it is :subselect1limit.

This problem is rectified by modifying line 55 of src/Sql/Platform/Mysql/SelectDecorator.php from:

return [$driver->formatParameterName('limit')];

to

return [$driver->formatParameterName($paramPrefix . 'limit')];
@smartwebproducts smartwebproducts changed the title MySQL SelectDecorator - subselect limit parameter wrong name MySQL SelectDecorator - subselect limit parameter not prefixed (fix included) May 16, 2018
@tptrixtop
Copy link
Contributor

Looks like that was fixed by this PR #300 )

@michalbundyra
Copy link
Member

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#50.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants