问题
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.
来源:https://stackoverflow.com/questions/32568921/with-zend-db-sql-select-can-i-manipulate-the-order-that-the-sql-parts-are-put-to