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

Zend\Db\Sql\Select::getSqlString(Zend\Db\Adapter\Platform\Mysql) doesn't work properly with limit param #3224

Closed
neilime opened this issue Dec 14, 2012 · 2 comments
Labels
Milestone

Comments

@neilime
Copy link
Contributor

neilime commented Dec 14, 2012

$oSelect = new \Zend\Db\Sql\Select('table_test');
$oSelect->columns(array('*'))->where(array('test' => 'ok')->limit(1);
echo $oSelect->getSqlString(new Zend\Db\Adapter\Platform\Mysql());
//SELECT `table_test`.* WHERE `table_test`.`test` = 'ok' limit '1'

Limit value should be 1 and not '1'...

@radnan
Copy link
Contributor

radnan commented Jan 22, 2013

This might be a bit late for this, but it looks like the code to write the SQL queries is baked into the query builders - Zend\Db\Sql\Select::process* methods. Shouldn't this be part of the platform implementation? So the above code should really look at Zend\Db\Adapter\Platform\Mysql to write out the actual queries.

@ralphschindler
Copy link
Member

Use the SQL Abstraction object (Zend\Db\Sql\Sql):

use Zend\Db\Sql\Sql;
$sql = new Sql($adapter);
$oSelect = $sql->select('table_test');
$oSelect->columns(array('*'))->where(array('test' => 'ok')->limit(1);
$sqlString = $sql->getSqlStringForSqlObject($oSelect);

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

No branches or pull requests

3 participants