From 52522d0a2eb5e0bb26e525c3424db82bd73fab08 Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Wed, 31 May 2017 15:28:33 +1200 Subject: [PATCH] NEW update the syntax for making a database query to be compatible with PostgreSQL --- code/extensions/ElementPageExtension.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/extensions/ElementPageExtension.php b/code/extensions/ElementPageExtension.php index 942804d4..d1e645a8 100644 --- a/code/extensions/ElementPageExtension.php +++ b/code/extensions/ElementPageExtension.php @@ -318,7 +318,7 @@ public function onAfterDuplicate($duplicatePage) $duplicateWidget = $originalWidget->duplicate(true); // manually set the ParentID of each widget, so we don't get versioning issues - DB::query(sprintf("UPDATE Widget SET ParentID = %d WHERE ID = %d", $duplicateWidgetArea->ID, $duplicateWidget->ID)); + DB::query(sprintf("UPDATE \"Widget\" SET \"ParentID\" = '%d' WHERE \"ID\" = '%d'", $duplicateWidgetArea->ID, $duplicateWidget->ID)); } } } @@ -340,7 +340,7 @@ public function onAfterDuplicateToSubsite($originalPage) $duplicateWidget = $originalWidget->duplicate(true); // manually set the ParentID of each widget, so we don't get versioning issues - DB::query(sprintf("UPDATE Widget SET ParentID = %d WHERE ID = %d", $duplicateWidgetArea->ID, $duplicateWidget->ID)); + DB::query(sprintf("UPDATE \"Widget|\" SET \"ParentID\" = '%d' WHERE \"ID\" = '%d'", $duplicateWidgetArea->ID, $duplicateWidget->ID)); } } @@ -350,7 +350,7 @@ public function onAfterDuplicateToSubsite($originalPage) public function onAfterPublish() { if ($id = $this->owner->ElementAreaID) { - $widgets = Versioned::get_by_stage('BaseElement', 'Stage', "ParentID = '$id'"); + $widgets = Versioned::get_by_stage('BaseElement', 'Stage', "\"ParentID\" = '$id'"); $staged = array(); foreach ($widgets as $widget) { @@ -360,7 +360,7 @@ public function onAfterPublish() } // remove any elements that are on live but not in draft. - $widgets = Versioned::get_by_stage('BaseElement', 'Live', "ParentID = '$id'"); + $widgets = Versioned::get_by_stage('BaseElement', 'Live', "\"ParentID\" = '$id'"); foreach ($widgets as $widget) { if (!in_array($widget->ID, $staged)) { @@ -386,7 +386,7 @@ public function onBeforeRollback($version) return; } if ($id = $this->owner->ElementAreaID) { - $widgets = Versioned::get_by_stage('BaseElement', 'Live', "ParentID = '$id'"); + $widgets = Versioned::get_by_stage('BaseElement', 'Live', "\"ParentID\" = '$id'"); $staged = array(); foreach ($widgets as $widget) {