Skip to content
This repository
Browse code

FIXED: Compatibility fixes for MS SQL Server. Replaced back ticks (wh…

…ich are mysql specific) with double quotes
  • Loading branch information...
commit f7ffb79542c609e24237f2d6d1522ada48dfc948 1 parent f0340e6
Damian Mooyman authored August 21, 2012

Showing 1 changed file with 15 additions and 15 deletions. Show diff stats Hide diff stats

  1. 30  model/Versioned.php
30  model/Versioned.php
@@ -162,16 +162,16 @@ function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
162 162
 			// Link to the version archived on that date
163 163
 			$safeDate = Convert::raw2sql($date);
164 164
 			$query->addWhere(
165  
-					"`{$baseTable}_versions`.`Version` IN 
  165
+					"\"{$baseTable}_versions\".\"Version\" IN 
166 166
 					(SELECT LatestVersion FROM 
167 167
 						(SELECT 
168  
-							`{$baseTable}_versions`.`RecordID`, 
169  
-							MAX(`{$baseTable}_versions`.`Version`) AS LatestVersion
170  
-							FROM `{$baseTable}_versions`
171  
-							WHERE `{$baseTable}_versions`.`LastEdited` <= '$safeDate'
172  
-							GROUP BY `{$baseTable}_versions`.`RecordID`
173  
-						) AS `{$baseTable}_versions_latest`
174  
-						WHERE `{$baseTable}_versions_latest`.`RecordID` = `{$baseTable}_versions`.`RecordID`
  168
+							\"{$baseTable}_versions\".\"RecordID\", 
  169
+							MAX(\"{$baseTable}_versions\".\"Version\") AS LatestVersion
  170
+							FROM \"{$baseTable}_versions\"
  171
+							WHERE \"{$baseTable}_versions\".\"LastEdited\" <= '$safeDate'
  172
+							GROUP BY \"{$baseTable}_versions\".\"RecordID\"
  173
+						) AS \"{$baseTable}_versions_latest\"
  174
+						WHERE \"{$baseTable}_versions_latest\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\"
175 175
 					)");
176 176
 			break;
177 177
 		
@@ -214,15 +214,15 @@ function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
214 214
 			// This provides "show all, including deleted" functonality
215 215
 			if($dataQuery->getQueryParam('Versioned.mode') == 'latest_versions') {
216 216
 				$query->addWhere(
217  
-					"`{$alias}_versions`.`Version` IN 
  217
+					"\"{$alias}_versions\".\"Version\" IN 
218 218
 					(SELECT LatestVersion FROM 
219 219
 						(SELECT 
220  
-							`{$alias}_versions`.`RecordID`, 
221  
-							MAX(`{$alias}_versions`.`Version`) AS LatestVersion
222  
-							FROM `{$alias}_versions`
223  
-							GROUP BY `{$alias}_versions`.`RecordID`
224  
-						) AS `{$alias}_versions_latest`
225  
-						WHERE `{$alias}_versions_latest`.`RecordID` = `{$alias}_versions`.`RecordID`
  220
+							\"{$alias}_versions\".\"RecordID\", 
  221
+							MAX(\"{$alias}_versions\".\"Version\") AS LatestVersion
  222
+							FROM \"{$alias}_versions\"
  223
+							GROUP BY \"{$alias}_versions\".\"RecordID\"
  224
+						) AS \"{$alias}_versions_latest\"
  225
+						WHERE \"{$alias}_versions_latest\".\"RecordID\" = \"{$alias}_versions\".\"RecordID\"
226 226
 					)");
227 227
 			}
228 228
 			break;

0 notes on commit f7ffb79

Please sign in to comment.
Something went wrong with that request. Please try again.