We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
limit
Briefly: SQL queries fails when few limit statements is used (sub-select, maybe unions)
Context: PDO Mysql driver
Expected SQL (simplified):
SELECT (SELECT column FROM foo LIMIT 1) AS column FROM bar LIMIT 99
PHP code to build them
$subSelect = new Select('foo'); $subSelect->columns(['column'])->limit(1); $select = new Select('bar'); $select->columns(['column' => $subSelect])->limit(99); $statement = $sql->prepareStatementForSqlObject($select); print_r($statement);
Output (simplified)
[sql] => SELECT (SELECT `foo`.`column` AS `column` FROM `foo` LIMIT :limit) AS `column` FROM `bar` LIMIT :limit [parameterContainer] => Zend\Db\Adapter\ParameterContainer Object ( [data] => Array ( [limit] => 99 ) [positions] => Array ( [0] => limit ) )
Same value sent to mysql for both limit statements:
SELECT (SELECT column FROM foo LIMIT 99) AS column FROM bar LIMIT 99
Test: autowp/zend-db@95efe84
The only workaround is to create sub-select with SQL-string
Originally posted by @autowp at zendframework/zend-db#262
The text was updated successfully, but these errors were encountered:
I tried the code and got the following output:
[sql:protected] => SELECT (SELECT `foo`.`column` AS `column` FROM `foo` LIMIT :subselect1limit) AS `column` FROM `bar` LIMIT :limit [parameterContainer:protected] => Laminas\Db\Adapter\ParameterContainer Object ( [data:protected] => Array ( [subselect1limit] => 1 [limit] => 99 ) [positions:protected] => Array ( [0] => subselect1limit [1] => limit ) [errata:protected] => Array ( [subselect1limit] => integer [limit] => integer ) [maxLength:protected] => Array ( ) )
When printed echo $sql->getSqlStringForSqlObject($select);, it got:
echo $sql->getSqlStringForSqlObject($select);
SELECT (SELECT `foo`.`column` AS `column` FROM `foo` LIMIT 1) AS `column` FROM `bar` LIMIT 99
It seems already fixed by PR zendframework/zend-db#300 . Please re-create issue if problem persist.
Sorry, something went wrong.
No branches or pull requests
Briefly: SQL queries fails when few
limit
statements is used (sub-select, maybe unions)Context: PDO Mysql driver
Expected SQL (simplified):
PHP code to build them
Output (simplified)
Same value sent to mysql for both
limit
statements:Test: autowp/zend-db@95efe84
The only workaround is to create sub-select with SQL-string
Originally posted by @autowp at zendframework/zend-db#262
The text was updated successfully, but these errors were encountered: