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() #2545 issue in 2.0.7 #3911

Closed
bouks opened this issue Feb 27, 2013 · 6 comments
Closed

Zend\Db\Sql\Select getSqlString() #2545 issue in 2.0.7 #3911

bouks opened this issue Feb 27, 2013 · 6 comments
Labels

Comments

@bouks
Copy link

bouks commented Feb 27, 2013

Hi.

$sql = new \Zend\Db\Sql\Select();
$sql->from('tablename')
       ->columns(array('*'))
       ->limit(4);

var_dump($sql->getSqlString(new \Zend\Db\Adapter\Platform\Mysql()));

prints me :

SELECT `tablename`.* FROM `tablename` LIMIT '4'
@bouks
Copy link
Author

bouks commented Feb 27, 2013

in \Zend\Db\Sql\Select

function processLimit

if ($adapter) {
    ...
} else {
    $sql = $platform->quoteValue($this->limit);
}

There is the problem. The platform is in this present case \Zend\Db\Adapter\Platform\Mysql() so it should not quote a limit.

Same problem in processOffset

@bouks
Copy link
Author

bouks commented Feb 27, 2013

Ok... in the same way.

$select->from('foo')->where(array('y = z'));

as example in the zf2 doc

return

SELECT `foo`.* FROM `foo` WHERE y = z

without quoting neither y or z !

$select->from('foo')->where(array('y' => 'z'));

works well

Seems like the array('z <= p') style doesn't work.

@tux-rampage
Copy link
Contributor

Hi bouks,

$select->form('foo')->where(array('y = z'));

in this case your predicate is a literal expression. To me it's perfectly valid that nothing is quoted.
Trying to quote identifiers in a SQL expression requires too much "magic" imho. You should take a look at the available Predicate implementations.

Example:

$where = new Predicate();
$where->equalTo('y', 'z');
// ...

$select->where($where);

@bouks
Copy link
Author

bouks commented Feb 28, 2013

Hi tux.

Thank you for answer. I'm using predicates and array('key' => $val).
I just saw this problem in the doc.
It seems, then, that this literal "bug" is a zf2 doc problem and should be deleted, modified or precised.

limit and offset bug still open. :)

@ThaDafinser
Copy link
Contributor

@bouks does this bug still exists?
If there is a documentation bug please post it here: https://github.com/zendframework/zf2-documentation

@ralphschindler
Copy link
Member

Fixed in #2775

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

4 participants