with Zend\Db\Sql\Select can I manipulate the order

2019-08-08 01:40发布

I am using PDO Firebird with Zend\Db.

This is fine until i want to limit the number of records returned. I am using this code;

$select = $this->getSelect()
               ->limit($limit);

Which produces this SQL;

SELECT "MODELS".* FROM "MODELS" limit '10'

However firebird needs SQL like this;

SELECT first 10 "MODELS".* FROM "MODELS"

I can change the word 'limit' to 'first' by using this statement;

$select->setSpecification('limit', 'first %1$s');

But I can't figure out how i get it to put the limit (first) clause at the beginning of the SQL and not at the end.

I can't find the code in Zend\Db\Sql\Select that puts the SQL parts together.

1条回答
时光不老,我们不散
2楼-- · 2019-08-08 02:16

Actually, since version 2.0 Firebird supports ROWS clause which is in the end of the statement. So I quess you need to use something like

$select->setSpecification('limit', 'ROWS %1$s');

but I'm not familiar with the setSpecification syntax so you might need to change the format string.

查看更多
登录 后发表回答