From 8bb4d38ee01c8fbe1a16931c8f96e4e4945a8992 Mon Sep 17 00:00:00 2001
From: zYne <zYne@625475ce-881a-0410-a577-b389adb331d8>
Date: Sun, 18 Mar 2007 18:38:49 +0000
Subject: [PATCH]

---
 lib/Doctrine/Connection/Mssql.php | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/Doctrine/Connection/Mssql.php b/lib/Doctrine/Connection/Mssql.php
index e560a1959..c44ca7115 100644
--- a/lib/Doctrine/Connection/Mssql.php
+++ b/lib/Doctrine/Connection/Mssql.php
@@ -104,26 +104,26 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection
                 throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
             }
     
-            $orderby = stristr($sql, 'ORDER BY');
+            $orderby = stristr($query, 'ORDER BY');
             if ($orderby !== false) {
                 $sort = (stripos($orderby, 'desc') !== false) ? 'desc' : 'asc';
                 $order = str_ireplace('ORDER BY', '', $orderby);
                 $order = trim(preg_replace('/ASC|DESC/i', '', $order));
             }
     
-            $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $sql);
+            $query = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $query);
     
-            $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
+            $query = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $query . ') AS inner_tbl';
             if ($orderby !== false) {
-                $sql .= ' ORDER BY ' . $order . ' ';
-                $sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC';
+                $query .= ' ORDER BY ' . $order . ' ';
+                $query .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC';
             }
-            $sql .= ') AS outer_tbl';
+            $query .= ') AS outer_tbl';
             if ($orderby !== false) {
-                $sql .= ' ORDER BY ' . $order . ' ' . $sort;
+                $query .= ' ORDER BY ' . $order . ' ' . $sort;
             }
     
-            return $sql;
+            return $query;
 
         }