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 = "

". _t('CommentAdmin.APPROVEDCOMMENTS', 'Approved Comments')."

"; } else if($section == 'unmoderated') { - $filter = 'NeedsModeration=1'; + $filter = '"NeedsModeration"'; $title = "

"._t('CommentAdmin.COMMENTSAWAITINGMODERATION', 'Comments Awaiting Moderation')."

"; } else { - $filter = 'IsSpam=1'; + $filter = '"IsSpam"'; $title = "

"._t('CommentAdmin.SPAM', 'Spam')."

"; } - $filter .= ' AND ParentID>0'; + $filter .= ' AND "ParentID">0'; $tableFields = array( "Name" => _t('CommentAdmin.AUTHOR', 'Author'), @@ -125,7 +125,7 @@ class CommentAdmin extends LeftAndMain { if($_REQUEST['Comments']) { foreach($_REQUEST['Comments'] as $commentid) { - $comment = DataObject::get_one('PageComment', "\"PageComment\".ID = $commentid"); + $comment = DataObject::get_one('PageComment', "\"PageComment\".\"ID\" = $commentid"); if($comment) { $comment->delete(); $numComments++; @@ -144,7 +144,7 @@ JS; function deleteall() { $numComments = 0; - $spam = DataObject::get('PageComment', 'PageComment.IsSpam=1'); + $spam = DataObject::get('PageComment', '"PageComment"."IsSpam"'); if($spam) { $numComments = $spam->Count(); @@ -169,7 +169,7 @@ JS; if($_REQUEST['Comments']) { foreach($_REQUEST['Comments'] as $commentid) { - $comment = DataObject::get_one('PageComment', "\"PageComment\".ID = $commentid"); + $comment = DataObject::get_one('PageComment', "\"PageComment\".\"ID\" = $commentid"); if($comment) { $comment->IsSpam = true; $comment->NeedsModeration = false; @@ -208,7 +208,7 @@ JS; if($_REQUEST['Comments']) { foreach($_REQUEST['Comments'] as $commentid) { - $comment = DataObject::get_one('PageComment', "\"PageComment\".ID = $commentid"); + $comment = DataObject::get_one('PageComment', "\"PageComment\".\"ID\" = $commentid"); if($comment) { $comment->IsSpam = false; $comment->NeedsModeration = false; @@ -248,7 +248,7 @@ JS; if($_REQUEST['Comments']) { foreach($_REQUEST['Comments'] as $commentid) { - $comment = DataObject::get_one('PageComment', "\"PageComment\".ID = $commentid"); + $comment = DataObject::get_one('PageComment', "\"PageComment\".\"ID\" = $commentid"); if($comment) { $comment->IsSpam = false; $comment->NeedsModeration = false; @@ -272,21 +272,21 @@ JS; * Return the number of moderated comments */ function NumModerated() { - return DB::query("SELECT COUNT(*) FROM PageComment WHERE !IsSpam AND !NeedsModeration")->value(); + return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE NOT \"IsSpam\" AND NOT \"NeedsModeration\"")->value(); } /** * Return the number of unmoderated comments */ function NumUnmoderated() { - return DB::query("SELECT COUNT(*) FROM PageComment WHERE !IsSpam AND NeedsModeration")->value(); + return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE NOT \"IsSpam\" AND \"NeedsModeration\"")->value(); } /** * Return the number of comments marked as spam */ function NumSpam() { - return DB::query("SELECT COUNT(*) FROM PageComment WHERE IsSpam")->value(); + return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"IsSpam\"")->value(); } } diff --git a/code/FileList.php b/code/FileList.php index 9b3c486a..37aa69f7 100755 --- a/code/FileList.php +++ b/code/FileList.php @@ -14,7 +14,7 @@ class FileList extends TableListField { } function sourceItems() { - return DataObject::get("File", "ParentID = '" . $this->folder->ID . "' AND ClassName <> 'Folder'", "Title"); + return DataObject::get("File", "\"ParentID\" = '" . $this->folder->ID . "' AND \"ClassName\" <> 'Folder'", '"Title"'); } } diff --git a/code/ImageEditor.php b/code/ImageEditor.php index f993fc01..7edc2d3d 100644 --- a/code/ImageEditor.php +++ b/code/ImageEditor.php @@ -123,7 +123,7 @@ class ImageEditor extends Controller { if(strpos($originalFile,'?') !== false) $originalFile = substr($originalFile,0,strpos($originalFile,'?')); if($this->checkFileExists($originalFile) && $this->checkFileExists($editedFile)) { if($editedFile != $originalFile && copy($this->url2File($editedFile),$this->url2File($originalFile))) { - $image = DataObject::get_one('File','Filename = \'' . substr($this->url2File($originalFile),3) . '\''); + $image = DataObject::get_one('File','"Filename" = \'' . substr($this->url2File($originalFile),3) . '\''); $image->deleteFormattedImages(); $image->generateFormattedImage('AssetLibraryPreview'); } else { diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 1503155a..c2233261 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -85,7 +85,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { $fieldVal = $_REQUEST[$fieldName]; $result = ''; - $matches = DataObject::get($this->stat('subitem_class'),"$fieldName LIKE '" . addslashes($fieldVal) . "%'"); + $matches = DataObject::get($this->stat('subitem_class'),"\"$fieldName\" LIKE '" . addslashes($fieldVal) . "%'"); if($matches) { $result .= "