ZF-787: MS SQL Server: bug in Zend_Db_Adapter_Pdo_Mssql::limit()

Description

Zend_Db_Adapter_Pdo_Mssql::limit() incorrectly works with Zend_Db_Select generated queries. Zend_Db_Select generates queries with \n characters and limit() fails to patch them. This patch fixes this issue:

--- lib/Zend/Db/Adapter/Pdo/Mssql.php   (revision 16)
+++ lib/Zend/Db/Adapter/Pdo/Mssql.php   (working copy)
@@ -121,7 +121,7 @@
                 $order = trim(preg_replace('/ASC|DESC/i', '', $order));
             }

-            $sql = preg_replace('/^SELECT /i', 'SELECT TOP '.($count+$offset).' ', $sql);
+            $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP '.($count+$offset).' ', $sql);

             $sql = 'SELECT * FROM (SELECT TOP '.$count.' * FROM ('.$sql.') AS inner_tbl';
             if ($orderby !== false) {

Comments

Adjusting summary for vendor-dependent issue.

Appears fixed in changeset 3162

Indeed, fixed in revision 3162.