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

2019-08-08 02:04发布

问题:

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:

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.