From f2098eaac77da036df6a8108cc1fc79c2e78ec6b Mon Sep 17 00:00:00 2001 From: Andreas Piening Date: Thu, 28 Jan 2010 03:03:15 +0000 Subject: [PATCH] MINOR: replaced proprietary update query with one that is ANSI compliant in doPublish() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97705 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index c110cc230..cf4bd1c0b 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1896,24 +1896,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $this->write(); $this->publish("Stage", "Live"); - - if(DB::getConn() instanceof MySQLDatabase) { - // Special syntax for MySQL (grr!) - // More ANSI-compliant syntax - DB::query("UPDATE \"SiteTree_Live\", \"SiteTree\" - SET \"SiteTree_Live\".\"Sort\" = \"SiteTree\".\"Sort\" - WHERE \"SiteTree_Live\".\"ID\" = \"SiteTree\".\"ID\" - AND \"SiteTree_Live\".\"ParentID\" = " . sprintf('%d', $this->ParentID) ); + DB::query("UPDATE \"SiteTree_Live\" + SET \"Sort\" = (SELECT \"SiteTree\".\"Sort\" FROM \"SiteTree\" WHERE \"SiteTree_Live\".\"ID\" = \"SiteTree\".\"ID\") + WHERE EXISTS (SELECT \"SiteTree\".\"Sort\" FROM \"SiteTree\" WHERE \"SiteTree_Live\".\"ID\" = \"SiteTree\".\"ID\") AND \"ParentID\" = " . sprintf('%d', $this->ParentID) ); - } else { - // More ANSI-compliant syntax - DB::query("UPDATE \"SiteTree_Live\" - SET \"Sort\" = \"SiteTree\".\"Sort\" - FROM \"SiteTree\" - WHERE \"SiteTree_Live\".\"ID\" = \"SiteTree\".\"ID\" - AND \"SiteTree_Live\".\"ParentID\" = " . sprintf('%d', $this->ParentID) ); - } - // Publish any virtual pages that might need publishing $linkedPages = DataObject::get("VirtualPage", "\"CopyContentFromID\" = $this->ID"); if($linkedPages) foreach($linkedPages as $page) {