Skip to content

Commit

Permalink
NEW update the syntax for making a database query to be compatible wi…
Browse files Browse the repository at this point in the history
…th PostgreSQL
  • Loading branch information
Normann Lou committed May 31, 2017
1 parent 7b15395 commit 52522d0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions code/extensions/ElementPageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand All @@ -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));
}
}

Expand All @@ -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) {
Expand All @@ -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)) {
Expand All @@ -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) {
Expand Down

0 comments on commit 52522d0

Please sign in to comment.