with Zend\Db\Sql\Select can I manipulate the order that the SQL parts are put together?

一曲冷凌霜 提交于 2019-12-11 09:53:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!