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

Issue Type: Patch Created: 2007-01-23T06:38:25.000+0000 Last Updated: 2009-05-14T05:47:29.000+0000 Status: Resolved Fix version(s): - 0.8.0 (21/Feb/07)

Reporter: Andrey Lebedev (kedder) Assignee: Bill Karwin (bkarwin) Tags: - Zend_Db

Related issues: Attachments:


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:

<pre class="literal">
--- 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) {


Posted by Bill Karwin (bkarwin) on 2007-01-29T11:35:52.000+0000

Adjusting summary for vendor-dependent issue.

Posted by Jayson Minard (jayson) on 2007-02-05T02:44:54.000+0000

Appears fixed in changeset 3162

Posted by Bill Karwin (bkarwin) on 2007-02-06T17:26:55.000+0000

Indeed, fixed in revision 3162.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.