mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Updated SQL queries to be ansi compatable
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@66402 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
f9342e562c
commit
a93a0c3c95
@ -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) {
|
||||
@ -376,7 +376,7 @@ HTML;
|
||||
|
||||
$deleteList = '';
|
||||
if( $folderID ) {
|
||||
$remaining = DB::query("SELECT COUNT(*) FROM `File` WHERE `ParentID`=$folderID")->value();
|
||||
$remaining = DB::query("SELECT COUNT(*) FROM \"File\" WHERE \"ParentID\" = $folderID")->value();
|
||||
|
||||
if( !$remaining )
|
||||
$deleteList .= "Element.removeClassName(\$('sitetree').getTreeNodeByIdx( '$folderID' ).getElementsByTagName('a')[0],'contents');";
|
||||
|
@ -28,7 +28,7 @@ class AssetTableField extends ComplexTableField {
|
||||
if($SQL_search) {
|
||||
$searchFilters = array();
|
||||
foreach($SNG_file->searchableFields() as $fieldName => $fieldSpec) {
|
||||
if(strpos($fieldName, '.') === false) $searchFilters[] = "`$fieldName` LIKE '%{$SQL_search}%'";
|
||||
if(strpos($fieldName, '.') === false) $searchFilters[] = "\"$fieldName\" LIKE '%{$SQL_search}%'";
|
||||
}
|
||||
$this->sourceFilter = '(' . implode(' OR ', $searchFilters) . ')';
|
||||
}
|
||||
|
@ -360,13 +360,13 @@ JS;
|
||||
$treeClass = $this->stat('tree_class');
|
||||
|
||||
if($id && is_numeric($id)) {
|
||||
$record = DataObject::get_one( $treeClass, "`$treeClass`.ID = $id");
|
||||
$record = DataObject::get_one( $treeClass, "\"$treeClass\".ID = $id");
|
||||
|
||||
if(!$record) {
|
||||
// $record = Versioned::get_one_by_stage($treeClass, "Live", "`$treeClass`.ID = $id");
|
||||
// $record = Versioned::get_one_by_stage($treeClass, "Live", "\"$treeClass\".ID = $id");
|
||||
Versioned::reading_stage('Live');
|
||||
singleton($treeClass)->flushCache();
|
||||
$record = DataObject::get_one( $treeClass, "`$treeClass`.ID = $id");
|
||||
$record = DataObject::get_one( $treeClass, "\"$treeClass\".ID = $id");
|
||||
if($record) {
|
||||
$record->DeletedFromStage = true;
|
||||
} else {
|
||||
@ -400,7 +400,7 @@ JS;
|
||||
$idField->setValue($id);
|
||||
|
||||
if($record->ID && is_numeric( $record->ID ) ) {
|
||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "`SiteTree`.ID = $record->ID");
|
||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".ID = $record->ID");
|
||||
if($liveRecord) $liveURLField->setValue($liveRecord->AbsoluteLink());
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
@ -753,7 +753,7 @@ HTML;
|
||||
$pageID = $this->urlParams['ID'];
|
||||
$page = $this->getRecord($pageID);
|
||||
if($page) {
|
||||
$versions = $page->allVersions($_REQUEST['unpublished'] ? "" : "`SiteTree`.WasPublished = 1");
|
||||
$versions = $page->allVersions($_REQUEST['unpublished'] ? "" : "\"SiteTree\".WasPublished = 1");
|
||||
return array(
|
||||
'Versions' => $versions,
|
||||
);
|
||||
@ -797,7 +797,7 @@ HTML;
|
||||
$JS_title = Convert::raw2js($page->TreeTitle());
|
||||
|
||||
$JS_stageURL = $page->DeletedFromStage ? '' : Convert::raw2js($page->AbsoluteLink());
|
||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "`SiteTree`.ID = $page->ID");
|
||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".ID = $page->ID");
|
||||
$JS_liveURL = $liveRecord ? Convert::raw2js($liveRecord->AbsoluteLink()) : '';
|
||||
|
||||
FormResponse::add($this->getActionUpdateJS($page));
|
||||
@ -1075,7 +1075,7 @@ HTML;
|
||||
|
||||
// check to see if the record exists on the live site, if it doesn't remove the tree node
|
||||
// $_REQUEST['showqueries'] = 1 ;
|
||||
$liveRecord = Versioned::get_one_by_stage( $this->stat('tree_class'), 'Live', "`{$this->stat('tree_class')}`.`ID`={$id}");
|
||||
$liveRecord = Versioned::get_one_by_stage( $this->stat('tree_class'), 'Live', "\"{$this->stat('tree_class')}\".\"ID\"={$id}");
|
||||
|
||||
if($liveRecord) {
|
||||
$title = Convert::raw2js($record->TreeTitle());
|
||||
|
@ -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++;
|
||||
@ -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;
|
||||
|
@ -19,7 +19,7 @@ class CommentTableField extends ComplexTableField {
|
||||
// search
|
||||
$search = isset($_REQUEST['CommentSearch']) ? Convert::raw2sql($_REQUEST['CommentSearch']) : null;
|
||||
if(!empty($_REQUEST['CommentSearch'])) {
|
||||
$this->sourceFilter[] = "( `Name` LIKE '%$search%' OR `Comment` LIKE '%$search%')";
|
||||
$this->sourceFilter[] = "( \"Name\" LIKE '%$search%' OR \"Comment\" LIKE '%$search%')";
|
||||
}
|
||||
|
||||
Requirements::javascript(CMS_DIR . '/javascript/CommentTableField.js');
|
||||
|
@ -408,7 +408,7 @@ class _DiffEngine
|
||||
* We do something when a run of changed lines include a
|
||||
* line at one end and has an excluded, identical line at the other.
|
||||
* We are free to choose which identical line is included.
|
||||
* `compareseq' usually chooses the one at the beginning,
|
||||
* 'compareseq' usually chooses the one at the beginning,
|
||||
* but usually it is cleaner to consider the following identical line
|
||||
* to be the "change".
|
||||
*
|
||||
|
@ -433,7 +433,7 @@ JS;
|
||||
|
||||
$SQL_id = Convert::raw2sql($_REQUEST['ID']);
|
||||
if(substr($SQL_id,0,3) != 'new') {
|
||||
$record = DataObject::get_one($className, "`$className`.ID = {$SQL_id}");
|
||||
$record = DataObject::get_one($className, "\"$className\".ID = {$SQL_id}");
|
||||
if($record && !$record->canEdit()) return Security::permissionFailure($this);
|
||||
} else {
|
||||
if(!singleton($this->stat('tree_class'))->canCreate()) return Security::permissionFailure($this);
|
||||
@ -678,7 +678,7 @@ JS;
|
||||
|
||||
if(is_array($_REQUEST['ID'])) {
|
||||
if($_REQUEST['MovedNodeID']==0){ //Sorting root
|
||||
$movedNode = DataObject::get($className, "`ParentID`=0");
|
||||
$movedNode = DataObject::get($className, "\"ParentID\"=0");
|
||||
}else{
|
||||
$movedNode = DataObject::get_by_id($className, $_REQUEST['MovedNodeID']);
|
||||
}
|
||||
@ -694,7 +694,7 @@ JS;
|
||||
// Nodes that weren't "actually moved" shouldn't be registered as having been edited; do a direct SQL update instead
|
||||
} else if(is_numeric($id)) {
|
||||
++$counter;
|
||||
DB::query("UPDATE `$className` SET `Sort` = $counter WHERE `ID` = '$id'");
|
||||
DB::query("UPDATE \"$className\" SET \"Sort\" = $counter WHERE \"ID\" = '$id'");
|
||||
}
|
||||
}
|
||||
// Virtual pages require selected to be null if the page is the same.
|
||||
|
@ -104,7 +104,7 @@ class MemberTableField extends ComplexTableField {
|
||||
|
||||
// construct the filter and sort
|
||||
if(isset($_REQUEST['MemberOrderByField'])) {
|
||||
$this->sourceSort = '`' . Convert::raw2sql($_REQUEST['MemberOrderByField']) . '`' . Convert::raw2sql( $_REQUEST['MemberOrderByOrder'] );
|
||||
$this->sourceSort = '"' . Convert::raw2sql($_REQUEST['MemberOrderByField']) . '"' . Convert::raw2sql( $_REQUEST['MemberOrderByOrder'] );
|
||||
}
|
||||
|
||||
$SNG_member = singleton('Member');
|
||||
@ -114,7 +114,7 @@ class MemberTableField extends ComplexTableField {
|
||||
if(!empty($_REQUEST['MemberSearch'])) {
|
||||
$searchFilters = array();
|
||||
foreach($SNG_member->searchableFields() as $fieldName => $fieldSpec) {
|
||||
if(strpos($fieldName,'.') === false) $searchFilters[] = "`$fieldName` LIKE '%{$SQL_search}%'";
|
||||
if(strpos($fieldName,'.') === false) $searchFilters[] = "\"$fieldName\" LIKE '%{$SQL_search}%'";
|
||||
}
|
||||
$this->sourceFilter[] = '(' . implode(' OR ', $searchFilters) . ')';
|
||||
}
|
||||
@ -122,10 +122,10 @@ class MemberTableField extends ComplexTableField {
|
||||
// filter by groups
|
||||
// TODO Not implemented yet
|
||||
if(isset($_REQUEST['ctf'][$this->Name()]['GroupID']) && is_numeric($_REQUEST['ctf'][$this->Name()]['GroupID'])) {
|
||||
$this->sourceFilter[] = "`GroupID`='{$_REQUEST['ctf'][$this->Name()]['GroupID']}'";
|
||||
$this->sourceFilter[] = "\"GroupID\"='{$_REQUEST['ctf'][$this->Name()]['GroupID']}'";
|
||||
}
|
||||
|
||||
$this->sourceJoin = " INNER JOIN `Group_Members` ON `MemberID`=`Member`.`ID`";
|
||||
$this->sourceJoin = " INNER JOIN \"Group_Members\" ON \"MemberID\"=\"Member\".\"ID\"";
|
||||
$this->setFieldListCsv( $csvFieldList );
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
if($id == 'new') $id = null;
|
||||
|
||||
if($id) {
|
||||
$record = DataObject::get_one($className, "`$className`.ID = $id");
|
||||
$record = DataObject::get_one($className, "\"$className\".ID = $id");
|
||||
} else {
|
||||
$record = new $className();
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -67,8 +67,8 @@ class WidgetAreaEditor extends FormField {
|
||||
foreach(array_keys( $_REQUEST['Widget'] ) as $newWidgetID ) {
|
||||
$newWidgetData = $_REQUEST['Widget'][$newWidgetID];
|
||||
|
||||
// `ParentID`=0 is for the new page
|
||||
$widget = DataObject::get_one( 'Widget', "(`ParentID`='{$record->$name()->ID}' OR `ParentID`=0) AND `Widget`.`ID`='$newWidgetID'" );
|
||||
// \"ParentID\"=0 is for the new page
|
||||
$widget = DataObject::get_one( 'Widget', "(\"ParentID\"='{$record->$name()->ID}' OR \"ParentID\"=0) AND \"Widget\".\"ID\"='$newWidgetID'" );
|
||||
|
||||
// check if we are updating an existing widget
|
||||
if($widget && isset($missingWidgets[$widget->ID]))
|
||||
|
@ -26,7 +26,7 @@ abstract class StaticPublisher extends DataObjectDecorator {
|
||||
if($this->owner->hasMethod('pagesAffectedByChanges')) {
|
||||
$urls = $this->owner->pagesAffectedByChanges($original);
|
||||
} else {
|
||||
// $pages = array(Versioned::get_one_by_stage('SiteTree', 'Live', "`SiteTree`.ID = {$this->owner->ID}"));
|
||||
// $pages = array(Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".ID = {$this->owner->ID}"));
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Live', '', '', 10);
|
||||
foreach($pages as $page) {
|
||||
$urls[] = $page->Link();
|
||||
|
Loading…
Reference in New Issue
Block a user