BUGFIX Removed backticks from FileSubsites

This commit is contained in:
Sean Harvey 2010-03-09 01:12:49 +00:00
parent a43459515b
commit 92dd4b0c02

View File

@ -47,10 +47,6 @@ class FileSubsites extends DataObjectDecorator {
* Update any requests to limit the results to the current site
*/
function augmentSQL(SQLQuery &$query) {
if(defined('DB::USE_ANSI_SQL'))
$q="\"";
else $q='`';
// If you're querying by ID, ignore the sub-site - this is a bit ugly... (but it was WAYYYYYYYYY worse)
if(!$query->where || !preg_match('/\.(\'|"|`|)ID(\'|"|`|)/', $query->where[0])) {
if($context = DataObject::context_obj()) $subsiteID = (int) $context->SubsiteID;
@ -58,12 +54,12 @@ class FileSubsites extends DataObjectDecorator {
// The foreach is an ugly way of getting the first key :-)
foreach($query->from as $tableName => $info) {
$where = "{$q}$tableName{$q}.{$q}SubsiteID{$q} IN (0, $subsiteID)";
$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
$query->where[] = $where;
break;
}
$query->orderby = "\"SubsiteID\"" . ($query->orderby ? ', ' : '') . $query->orderby;
$query->orderby = "\"SubsiteID\"" . ($query->orderby ? ', ' : '') . $query->orderby;
}
}