diff --git a/code/AssetAdmin.php b/code/AssetAdmin.php index c0fdc967..f3e21864 100755 --- a/code/AssetAdmin.php +++ b/code/AssetAdmin.php @@ -237,7 +237,7 @@ JS $fileNames = array(); foreach($newFiles as $newFile) { $fileIDs[] = $newFile; - $fileObj = DataObject::get_one('File', "\"File\".ID=$newFile"); + $fileObj = DataObject::get_one('File', "\"File\".\"ID\"=$newFile"); $fileNames[] = $fileObj->Name; } @@ -314,7 +314,7 @@ HTML; $numFiles = 0; if($fileList != "''") { - $files = DataObject::get("File", "\"File\".ID IN ($fileList)"); + $files = DataObject::get("File", "\"File\".\"ID\" IN ($fileList)"); if($files) { foreach($files as $file) { if($file instanceof Image) { @@ -350,7 +350,7 @@ HTML; $brokenPageList = ''; if($fileList != "''") { - $files = DataObject::get("File", "\"File\".ID IN ($fileList)"); + $files = DataObject::get("File", "\"File\".\"ID\" IN ($fileList)"); if($files) { foreach($files as $file) { if($file instanceof Image) { diff --git a/code/AssetTableField.php b/code/AssetTableField.php index 76e788a6..0ec46d73 100755 --- a/code/AssetTableField.php +++ b/code/AssetTableField.php @@ -46,7 +46,7 @@ class AssetTableField extends ComplexTableField { function setFolder($folder) { $this->folder = $folder; $this->sourceFilter .= ($this->sourceFilter) ? " AND " : ""; - $this->sourceFilter .= " ParentID = '" . $folder->ID . "' AND ClassName <> 'Folder'"; + $this->sourceFilter .= " \"ParentID\" = '" . $folder->ID . "' AND \"ClassName\" <> 'Folder'"; } function Folder() { diff --git a/code/CMSMain.php b/code/CMSMain.php index 208be3ba..e098ce35 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -513,7 +513,7 @@ JS; // DataObject::fieldExists only checks the current class, not the hierarchy // This allows the CMS to set the correct sort value if($newItem->castingHelperPair('Sort')) { - $newItem->Sort = DB::query("SELECT MAX(Sort) FROM SiteTree WHERE ParentID = '" . Convert::raw2sql($parentID) . "'")->value() + 1; + $newItem->Sort = DB::query("SELECT MAX(\"Sort\") FROM \"SiteTree\" WHERE \"ParentID\" = '" . Convert::raw2sql($parentID) . "'")->value() + 1; } if( Member::currentUser() ) @@ -596,7 +596,7 @@ JS; */ public function delete($urlParams, $form) { $id = $_REQUEST['ID']; - $record = DataObject::get_one("SiteTree", "SiteTree.\"ID\" = $id"); + $record = DataObject::get_one("SiteTree", "\"SiteTree\".\"ID\" = $id"); if($record && !$record->canDelete()) return Security::permissionFailure(); $recordID = $record->ID; @@ -662,7 +662,7 @@ JS; if($groupIDs) { $groupList = implode(", ", $groupIDs); $members = DataObject::get("Member","","", - "INNER JOIN \"Group_Members\" ON \"Group_Members\".MemberID = \"Member\".ID AND \"Group_Members\".GroupID IN ($groupList)"); + "INNER JOIN \"Group_Members\" ON \"Group_Members\".\"MemberID\" = \"Member\".\"ID\" AND \"Group_Members\".\"GroupID\" IN ($groupList)"); } if($members) { @@ -687,7 +687,7 @@ HTML; } function tasklist() { - $tasks = DataObject::get("Page", "AssignedToID = " . Member::currentUserID(), "Created DESC"); + $tasks = DataObject::get("Page", "\"AssignedToID\" = " . Member::currentUserID(), "\"Created\" DESC"); if($tasks) { $data = new ArrayData(array( "Tasks" => $tasks, @@ -702,7 +702,7 @@ HTML; } function waitingon() { - $tasks = DataObject::get("Page", "RequestedByID = " . Member::currentUserID(), "Created DESC"); + $tasks = DataObject::get("Page", "\"RequestedByID\" = " . Member::currentUserID(), "\"Created\" DESC"); if($tasks) { $data = new ArrayData(array( "Tasks" => $tasks, @@ -718,7 +718,7 @@ HTML; function comments() { if($this->urlParams['ID']) { - $comments = DataObject::get("WorkflowPageComment", "PageID = " . $this->urlParams['ID'], "Created DESC"); + $comments = DataObject::get("WorkflowPageComment", "\"PageID\" = " . $this->urlParams['ID'], "\"Created\" DESC"); $data = new ArrayData(array( "Comments" => $comments, )); @@ -1169,7 +1169,7 @@ HTML; ini_set('max_execution_time', 0); $excludePages = split(" *, *", $_GET['exclude']); - $pages = DataObject::get("SiteTree", "ParentID = 0"); + $pages = DataObject::get("SiteTree", "\"ParentID\" = 0"); foreach($pages as $page) $pageArr[] = $page; while(list($i,$page) = each($pageArr)) { @@ -1241,7 +1241,7 @@ HTML; $restoredPage = Versioned::get_latest_version("SiteTree", $id); $restoredPage->ID = $restoredPage->RecordID; if(!DB::query("SELECT \"ID\" FROM \"SiteTree\" WHERE \"ID\" = $restoredPage->ID")->value()) { - DB::query("INSERT INTO \"SiteTree\" SET \"ID\" = $restoredPage->ID"); + DB::query("INSERT INTO \"SiteTree\" (\"ID\") VALUES ($restoredPage->ID)"); } $restoredPage->forceChange(); $restoredPage->writeWithoutVersion(); diff --git a/code/CommentAdmin.php b/code/CommentAdmin.php index 4c915507..a26a3bdc 100644 --- a/code/CommentAdmin.php +++ b/code/CommentAdmin.php @@ -55,17 +55,17 @@ class CommentAdmin extends LeftAndMain { $section = $this->Section(); if($section == 'approved') { - $filter = 'IsSpam=0 AND NeedsModeration=0'; + $filter = 'NOT "IsSpam" AND NOT "NeedsModeration"'; $title = "
'", "Title"); + return DataObject::get("SiteTree", "\"Content\" = '' OR \"Content\" IS NULL OR \"Content\" LIKE '' OR \"Content\" LIKE '
'", '"Title"'); } function fieldsToShow() { return array( @@ -87,7 +87,7 @@ class SideReport_RecentlyEdited extends SideReport { return _t('SideReport.LAST2WEEKS',"Pages edited in the last 2 weeks"); } function records() { - return DataObject::get("SiteTree", "\"SiteTree\".LastEdited > NOW() - INTERVAL 14 DAY", "\"SiteTree\".\"LastEdited\" DESC"); + return DataObject::get("SiteTree", "\"SiteTree\".\"LastEdited\" > NOW() - INTERVAL 14 DAY", "\"SiteTree\".\"LastEdited\" DESC"); } function fieldsToShow() { return array( @@ -101,7 +101,7 @@ class SideReport_ToDo extends SideReport { return _t('SideReport.TODO',"To do"); } function records() { - return DataObject::get("SiteTree", "\"SiteTree\".ToDo IS NOT NULL AND \"SiteTree\".ToDo <> ''", "\"SiteTree\".\"LastEdited\" DESC"); + return DataObject::get("SiteTree", "\"SiteTree\".\"ToDo\" IS NOT NULL AND \"SiteTree\".\"ToDo\" <> ''", "\"SiteTree\".\"LastEdited\" DESC"); } function fieldsToShow() { return array( diff --git a/code/ThumbnailStripField.php b/code/ThumbnailStripField.php index 9689f2f7..bf84bb4a 100755 --- a/code/ThumbnailStripField.php +++ b/code/ThumbnailStripField.php @@ -47,14 +47,14 @@ class ThumbnailStripField extends FormField { $folderList = $folder->getDescendantIDList('Folder'); array_unshift($folderList, $folder->ID); - $whereSQL = 'ParentID IN (' . implode(', ', $folderList) . ')'; - if($searchText) $whereSQL .= " AND Filename LIKE '%$searchText%'"; + $whereSQL = '"ParentID" IN (' . implode(', ', $folderList) . ')'; + if($searchText) $whereSQL .= " AND \"Filename\" LIKE '%$searchText%'"; $images = DataObject::get('Image', $whereSQL, 'Title'); } else { if($searchText) { - $whereSQL = "Filename LIKE '%$searchText%'"; + $whereSQL = "\"Filename\" LIKE '%$searchText%'"; $images = DataObject::get('Image', $whereSQL, 'Title'); } @@ -113,13 +113,13 @@ class ThumbnailStripField extends FormField { $folderList = $folder->getDescendantIDList('Folder'); array_unshift($folderList, $folder->ID); - $whereSQL = "ParentID IN (" . implode(', ', $folderList) . ") AND Filename LIKE '%.swf'"; - if($searchText) $whereSQL .= " AND Filename LIKE '%$searchText%'"; + $whereSQL = "\"ParentID\" IN (" . implode(', ', $folderList) . ") AND \"Filename\" LIKE '%.swf'"; + if($searchText) $whereSQL .= " AND \"Filename\" LIKE '%$searchText%'"; $flashObjects = DataObject::get('File', $whereSQL); } else { if($searchText) { - $flashObjects = DataObject::get('File', "Filename LIKE '%$searchText%' AND Filename LIKE '%.swf'"); + $flashObjects = DataObject::get('File', "\"Filename\" LIKE '%$searchText%' AND \"Filename\" LIKE '%.swf'"); } } diff --git a/code/sitefeatures/PageComment.php b/code/sitefeatures/PageComment.php index acdcf596..77fd150b 100755 --- a/code/sitefeatures/PageComment.php +++ b/code/sitefeatures/PageComment.php @@ -123,8 +123,8 @@ class PageComment extends DataObject { class PageComment_Controller extends Controller { function rss() { - $parentcheck = isset($_REQUEST['pageid']) ? "ParentID = " . (int) $_REQUEST['pageid'] : "ParentID > 0"; - $comments = DataObject::get("PageComment", "$parentcheck AND IsSpam=0", "Created DESC", "", 10); + $parentcheck = isset($_REQUEST['pageid']) ? "\"ParentID\" = " . (int) $_REQUEST['pageid'] : "\"ParentID\" > 0"; + $comments = DataObject::get("PageComment", "$parentcheck AND NOT \"IsSpam\"", "\"Created\" DESC", "", 10); if(!isset($comments)) { $comments = new DataObjectSet(); } diff --git a/tasks/SiteTreeMaintenanceTask.php b/tasks/SiteTreeMaintenanceTask.php index 2f53d4f1..4ffd4644 100644 --- a/tasks/SiteTreeMaintenanceTask.php +++ b/tasks/SiteTreeMaintenanceTask.php @@ -10,7 +10,7 @@ class SiteTreeMaintenanceTask extends Controller { function makelinksunique() { $badURLs = "'" . implode("', '", DB::query("SELECT URLSegment, count(*) FROM SiteTree GROUP BY URLSegment HAVING count(*) > 1")->column()) . "'"; - $pages = DataObject::get("SiteTree", "URLSegment IN ($badURLs)"); + $pages = DataObject::get("SiteTree", "\"URLSegment\" IN ($badURLs)"); foreach($pages as $page) { echo "