Want more features on Pastebin? Sign Up, it's FREE!
Guest

miiihi

By: a guest on Jan 12th, 2011  |  syntax: Diff  |  size: 21.99 KB  |  views: 65  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/dataobject_manager/code/AssetManager.php b/dataobject_manager/code/AssetManager.php
  2. index 358c2ec..c7ea141 100644
  3. --- a/dataobject_manager/code/AssetManager.php
  4. +++ b/dataobject_manager/code/AssetManager.php
  5. @@ -24,7 +24,7 @@ class AssetManager extends FileDataObjectManager
  6.      $fields->push(new SimpleTreeDropdownField('ParentID','Folder',"Folder"));
  7.      $fields->push(new HiddenField('ID','',$controller->ID));
  8.      
  9. -    parent::__construct($controller, $name, $sourceClass, null, $headings, $fields, "Classname != 'Folder'");
  10. +    parent::__construct($controller, $name, $sourceClass, null, $headings, $fields, "\"Classname\" != 'Folder'");
  11.    }
  12.    
  13.         function FieldHolder()
  14. diff --git a/dataobject_manager/code/AssetManagerFolder.php b/dataobject_manager/code/AssetManagerFolder.php
  15. index eb34ea2..5947ea9 100644
  16. --- a/dataobject_manager/code/AssetManagerFolder.php
  17. +++ b/dataobject_manager/code/AssetManagerFolder.php
  18. @@ -15,7 +15,7 @@ class AssetManagerFolder extends DataObjectDecorator
  19.        'Title' => 30,
  20.        'Filename' => 70
  21.      ));
  22. -    $folder_filter = "(Classname != 'Folder' AND ParentID = ".$this->owner->ID.")";
  23. +    $folder_filter = "(\"Classname\" != 'Folder' AND \"ParentID\" = ".$this->owner->ID.")";
  24.      $filter = $a->sourceFilter ? "({$a->sourceFilter}) AND $folder_filter" : $folder_filter;
  25.      $a->setSourceFilter($filter);
  26.      $a->setParentClass("Folder");
  27. diff --git a/dataobject_manager/code/DataObjectManager.php b/dataobject_manager/code/DataObjectManager.php
  28. index c4bf4eb..db7aa0b 100644
  29. --- a/dataobject_manager/code/DataObjectManager.php
  30. +++ b/dataobject_manager/code/DataObjectManager.php
  31. @@ -201,10 +201,10 @@ class DataObjectManager extends ComplexTableField
  32.                
  33.                 if($this->Sortable() && (!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == "SortOrder")) {
  34.                         $this->sort = "SortOrder";
  35. -                       $this->sourceSort = "SortOrder ASC";
  36. +                       $this->sourceSort = "\"SortOrder\" ASC";
  37.                 }
  38.                 elseif(isset($_REQUEST['ctf'][$this->Name()]['sort']) && !empty($_REQUEST['ctf'][$this->Name()]['sort'])) {
  39. -                       $this->sourceSort = $_REQUEST['ctf'][$this->Name()]['sort'] . " " . $this->sort_dir;
  40. +                       $this->sourceSort = "\"" . $_REQUEST['ctf'][$this->Name()]['sort'] . "\" " . $this->sort_dir;
  41.                 }
  42.                 else {
  43.                         $this->sourceSort = singleton($this->sourceClass())->stat('default_sort');
  44. @@ -749,7 +749,7 @@ class DataObjectManager_Controller extends Controller
  45.                     if(!isset($relationName)) return false;
  46.                     list($parentClass, $componentClass, $parentField, $componentField, $table) = singleton($ownerClass)->many_many($relationName);            
  47.                     foreach($map as $sort => $id)
  48. -                     DB::query("UPDATE `$table` SET SortOrder = $sort WHERE {$className}ID = $id AND {$ownerClass}ID = $controllerID");
  49. +                     DB::query("UPDATE \"$table\" SET \"SortOrder\" = $sort WHERE \"{$className}ID\" = $id AND \"{$ownerClass}ID\" = $controllerID");
  50.                   }
  51.                   else {
  52.                     foreach($map as $sort => $id) {
  53. diff --git a/dataobject_manager/code/FileDataObjectManager.php b/dataobject_manager/code/FileDataObjectManager.php
  54. index 92ced06..9ac3829 100644
  55. --- a/dataobject_manager/code/FileDataObjectManager.php
  56. +++ b/dataobject_manager/code/FileDataObjectManager.php
  57. @@ -138,11 +138,11 @@ class FileDataObjectManager extends DataObjectManager
  58.         protected function getImportFolderHierarchy($parentID, $level = 0)
  59.         {
  60.                 $options = array();            
  61. -               if($children = DataObject::get("Folder", "ParentID = $parentID")) {
  62. +               if($children = DataObject::get("Folder", "\"ParentID\" = $parentID")) {
  63.                         foreach($children as $child) {
  64.                                 $indent="";
  65.                                 for($i=0;$i<$level;$i++) $indent .= "&nbsp;&nbsp;";
  66. -                               $files = DataObject::get($this->importClass, "ClassName != 'Folder' AND ParentID = $child->ID");
  67. +                               $files = DataObject::get($this->importClass, "\"ClassName\" != 'Folder' AND \"ParentID\" = $child->ID");
  68.                                 $count = $files ? $files->Count() : "0";
  69.                                 $options[$this->importLinkFor($child)] = $indent.$child->Title . " <span>($count files)</span>";
  70.                                 $options += $this->getImportFolderHierarchy($child->ID, $level+1);
  71. @@ -154,7 +154,7 @@ class FileDataObjectManager extends DataObjectManager
  72.         protected function getUploadFolderHierarchy($parentID, $level = 0)
  73.         {
  74.                 $options = array();            
  75. -               if($children = DataObject::get("Folder", "ParentID = $parentID")) {
  76. +               if($children = DataObject::get("Folder", "\"ParentID\" = $parentID")) {
  77.                         foreach($children as $child) {
  78.                                 $indent="";
  79.                                 for($i=0;$i<$level;$i++) $indent .= "&nbsp;&nbsp;";
  80. @@ -565,7 +565,7 @@ class FileDataObjectManager extends DataObjectManager
  81.         protected function ImportForm($folder_id = null)
  82.         {
  83.                 $folder_id = isset($_POST['folder_id']) ? $_POST['folder_id'] : $this->importFolderID;;
  84. -               if($files = DataObject::get($this->importClass, "ClassName != 'Folder' AND ParentID = $folder_id"))
  85. +               if($files = DataObject::get($this->importClass, "\"ClassName\" != 'Folder' AND \"ParentID\" = $folder_id"))
  86.                         $fields = $this->getImportFields();
  87.                         $fields->push(new HiddenField('folder_id','',$folder_id));
  88.                         $fields->push(new LiteralField('select','<div class="select"><span>Select</span>: <a href="javascript:void(0)" rel="all">all</a> | <a href="javascript:void(0)" rel="none">none</a></div>'));
  89. diff --git a/dataobject_manager/code/HasManyDataObjectManager.php b/dataobject_manager/code/HasManyDataObjectManager.php
  90. index add6956..c91962d 100644
  91. --- a/dataobject_manager/code/HasManyDataObjectManager.php
  92. +++ b/dataobject_manager/code/HasManyDataObjectManager.php
  93. @@ -62,9 +62,9 @@ class HasManyDataObjectManager extends DataObjectManager
  94.         function getQuery($limitClause = null) {
  95.                 if($this->customQuery) {
  96.                         $query = $this->customQuery;
  97. -                       $query->select[] = "{$this->sourceClass}.ID AS ID";
  98. -                       $query->select[] = "{$this->sourceClass}.ClassName AS ClassName";
  99. -                       $query->select[] = "{$this->sourceClass}.ClassName AS RecordClassName";
  100. +                       $query->select[] = "\"{$this->sourceClass}\".\"ID\" AS \"ID\"";
  101. +                       $query->select[] = "\"{$this->sourceClass}\".\"ClassName\" AS \"ClassName\"";
  102. +                       $query->select[] = "\"{$this->sourceClass}\".\"ClassName\" AS \"RecordClassName\"";
  103.                 }
  104.                 else {
  105.                         $query = singleton($this->sourceClass)->extendedSQL($this->sourceFilter, $this->sourceSort, $limitClause, $this->sourceJoin);
  106. diff --git a/dataobject_manager/code/HasManyFileDataObjectManager.php b/dataobject_manager/code/HasManyFileDataObjectManager.php
  107. index 1af7d02..d69d0c2 100644
  108. --- a/dataobject_manager/code/HasManyFileDataObjectManager.php
  109. +++ b/dataobject_manager/code/HasManyFileDataObjectManager.php
  110. @@ -59,9 +59,9 @@ class HasManyFileDataObjectManager extends FileDataObjectManager
  111.         function getQuery($limitClause = null) {
  112.                 if($this->customQuery) {
  113.                         $query = $this->customQuery;
  114. -                       $query->select[] = "{$this->sourceClass}.ID AS ID";
  115. -                       $query->select[] = "{$this->sourceClass}.ClassName AS ClassName";
  116. -                       $query->select[] = "{$this->sourceClass}.ClassName AS RecordClassName";
  117. +                       $query->select[] = "\"{$this->sourceClass}\".\"ID\" AS \"ID\"";
  118. +                       $query->select[] = "\"{$this->sourceClass}\".\"ClassName\" AS \"ClassName\"";
  119. +                       $query->select[] = "\"{$this->sourceClass}\".\"ClassName\" AS \"RecordClassName\"";
  120.                 }
  121.                 else {
  122.                         $query = singleton($this->sourceClass)->extendedSQL($this->sourceFilter, $this->sourceSort, $limitClause, $this->sourceJoin);
  123. diff --git a/dataobject_manager/code/HasOneDataObjectManager.php b/dataobject_manager/code/HasOneDataObjectManager.php
  124. index 18042b7..dd9ba63 100644
  125. --- a/dataobject_manager/code/HasOneDataObjectManager.php
  126. +++ b/dataobject_manager/code/HasOneDataObjectManager.php
  127. @@ -37,7 +37,7 @@ class HasOneDataObjectManager extends HasManyDataObjectManager
  128.         }
  129.        
  130.         function isChildSet($childID) {
  131. -               return DataObject::get($this->controllerClass(), '`' . $this->joinField . "` = '$childID'");
  132. +               return DataObject::get($this->controllerClass(), '"' . $this->joinField . "\" = '$childID'");
  133.         }
  134.        
  135.         function ExtraData() {
  136. diff --git a/dataobject_manager/code/HasOneFileDataObjectManager.php b/dataobject_manager/code/HasOneFileDataObjectManager.php
  137. index a504400..0b62258 100644
  138. --- a/dataobject_manager/code/HasOneFileDataObjectManager.php
  139. +++ b/dataobject_manager/code/HasOneFileDataObjectManager.php
  140. @@ -37,7 +37,7 @@ class HasOneFileDataObjectManager extends HasManyFileDataObjectManager
  141.         }
  142.        
  143.         function isChildSet($childID) {
  144. -               return DataObject::get($this->controllerClass(), '`' . $this->joinField . "` = '$childID'");
  145. +               return DataObject::get($this->controllerClass(), '"' . $this->joinField . "\" = '$childID'");
  146.         }
  147.        
  148.         function ExtraData() {
  149. diff --git a/dataobject_manager/code/ImageAssetManager.php b/dataobject_manager/code/ImageAssetManager.php
  150. index ad1fd35..1c2ff4f 100644
  151. --- a/dataobject_manager/code/ImageAssetManager.php
  152. +++ b/dataobject_manager/code/ImageAssetManager.php
  153. @@ -23,7 +23,7 @@ class ImageAssetManager extends ImageDataObjectManager
  154.      $fields->push(new SimpleTreeDropdownField('ParentID','Folder',"Folder"));
  155.      $fields->push(new HiddenField('ID','',$controller->ID));
  156.      
  157. -    parent::__construct($controller, $name, $sourceClass, null, $headings, $fields, "Classname != 'Folder'");
  158. +    parent::__construct($controller, $name, $sourceClass, null, $headings, $fields, "\"Classname\" != 'Folder'");
  159.    }
  160.  
  161.  }
  162. \ No newline at end of file
  163. diff --git a/dataobject_manager/code/ManyManyDataObjectManager.php b/dataobject_manager/code/ManyManyDataObjectManager.php
  164. index d962b9f..5c16af6 100644
  165. --- a/dataobject_manager/code/ManyManyDataObjectManager.php
  166. +++ b/dataobject_manager/code/ManyManyDataObjectManager.php
  167. @@ -60,7 +60,7 @@ class ManyManyDataObjectManager extends HasManyDataObjectManager
  168.                         $sourceField = 'Child';
  169.                 $parentID = $this->controller->ID;
  170.                
  171. -               $this->sourceJoin .= " LEFT JOIN `$manyManyTable` ON (`$source`.`ID` = `{$sourceField}ID` AND `$manyManyTable`.`{$this->manyManyParentClass}ID` = '$parentID')";
  172. +               $this->sourceJoin .= " LEFT JOIN \"$manyManyTable\" ON (\"$source\".\"ID\" = \"{$sourceField}ID\" AND \"$manyManyTable\".\"{$this->manyManyParentClass}ID\" = '$parentID')";
  173.                
  174.                 $this->joinField = 'Checked';
  175.                 if(isset($_REQUEST['ctf'][$this->Name()]['only_related']))
  176. @@ -80,32 +80,32 @@ class ManyManyDataObjectManager extends HasManyDataObjectManager
  177.         }
  178.        
  179.  
  180. -       protected function loadSort()
  181. -       {
  182. +       protected function loadSort() {
  183.  
  184.                 if($this->ShowAll())
  185.                         $this->setPageSize(999);
  186.  
  187. +               $original_sort = $this->sourceSort;
  188.             if(SortableDataObject::is_sortable_many_many($this->sourceClass(), $this->manyManyParentClass)) {
  189.               list($parentClass, $componentClass, $parentField, $componentField, $table) = singleton($this->controllerClass())->many_many($this->Name());
  190.               $sort_column = "MMSort";
  191.               if(!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == $sort_column) {
  192.                 $this->sort = $sort_column;
  193. -               $this->sourceSort = "$sort_column " . SortableDataObject::$sort_dir;
  194. -                       $this->sourceSort .= ",Checked DESC";
  195. +               $this->sourceSort = "\"$sort_column\" " . SortableDataObject::$sort_dir;
  196. +                       $this->sourceSort .= ", \"Checked\" DESC";
  197.               }
  198.             }
  199.                 elseif($this->Sortable() && (!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == "SortOrder")) {
  200.                         $this->sort = "SortOrder";
  201. -                       $this->sourceSort = "SortOrder " . SortableDataObject::$sort_dir;
  202. -                       $this->sourceSort .= ", Checked DESC";
  203. +                       $this->sourceSort = "\"SortOrder\" " . SortableDataObject::$sort_dir;
  204. +                       $this->sourceSort .= ", \"Checked\" DESC";
  205.                 }
  206.                
  207.                 elseif(isset($_REQUEST['ctf'][$this->Name()]['sort']) && !empty($_REQUEST['ctf'][$this->Name()]['sort'])) {
  208. -                       $this->sourceSort = $_REQUEST['ctf'][$this->Name()]['sort'] . " " . $this->sort_dir;
  209. +                       $this->sourceSort = "\"".$_REQUEST['ctf'][$this->Name()]['sort'] . "\" " . $this->sort_dir;
  210.                 }
  211.  
  212. -              
  213. +               if ($original_sort && $original_sort != $this->sourceSort) $this->sourceSort .= ', '.$original_sort;
  214.         }
  215.        
  216.        
  217. @@ -140,9 +140,9 @@ class ManyManyDataObjectManager extends HasManyDataObjectManager
  218.         function getQuery($limitClause = null) {
  219.                 if($this->customQuery) {
  220.                         $query = $this->customQuery;
  221. -                       $query->select[] = "{$this->sourceClass}.ID AS ID";
  222. -                       $query->select[] = "{$this->sourceClass}.ClassName AS ClassName";
  223. -                       $query->select[] = "{$this->sourceClass}.ClassName AS RecordClassName";
  224. +                       $query->select[] = "\"{$this->sourceClass}\".\"ID\" AS \"ID\"";
  225. +                       $query->select[] = "\"{$this->sourceClass}\".\"ClassName\" AS \"ClassName\"";
  226. +                       $query->select[] = "\"{$this->sourceClass}\".\"ClassName\" AS \"RecordClassName\"";
  227.                 }
  228.                 else {
  229.                         $query = singleton($this->sourceClass)->extendedSQL($this->sourceFilter, $this->sourceSort, $limitClause, $this->sourceJoin);
  230. @@ -151,18 +151,27 @@ class ManyManyDataObjectManager extends HasManyDataObjectManager
  231.  
  232.                         $SNG = singleton($this->sourceClass);
  233.                         foreach($this->FieldList() as $k => $title) {
  234. -                               if(! $SNG->hasField($k) && ! $SNG->hasMethod('get' . $k))
  235. +                               if(! $SNG->hasField($k) && ! $SNG->hasMethod('get' . $k)) {
  236. +                                       // everything we add to select must be added to groupby too...
  237.                                         $query->select[] = $k;
  238. +                                       $query->groupby[] = $k;
  239. +                               }
  240.                         }
  241.                         $parent = $this->controllerClass();
  242.                         $mm = $this->manyManyTable;
  243. -                       $if_clause = "IF(`$mm`.`{$this->manyManyParentClass}ID` IS NULL, '0', '1')";
  244. -                       $query->select[] = "$if_clause AS Checked";
  245. -                   if(SortableDataObject::is_sortable_many_many($this->sourceClass(), $this->manyManyParentClass))
  246. -                               $query->select[] = "IFNULL(`$mm`.SortOrder,9999999) AS MMSort";
  247. +                       $when_clause = "CASE WHEN \"$mm\".\"{$this->manyManyParentClass}ID\" IS NULL THEN '0' ELSE '1' END";
  248. +                       $query->select[] = "$when_clause AS \"Checked\"";
  249. +                       // everything we add to select must be added to groupby too...
  250. +                       $query->groupby[] = $when_clause;
  251. +                      
  252. +                   if (SortableDataObject::is_sortable_many_many($this->sourceClass(), $this->manyManyParentClass)) {
  253. +                               $query->select[] = "COALESCE(\"$mm\".\"SortOrder\",9999999) AS \"MMSort\"";
  254. +                               // everything we add to select must be added to groupby too...
  255. +                               $query->groupby[] = "COALESCE(\"$mm\".\"SortOrder\",9999999)";
  256. +                       }
  257.                        
  258.                         if($this->OnlyRelated())
  259. -                        $query->where[] = $if_clause;
  260. +                               $query->where[] = "(\"$mm\".\"{$this->manyManyParentClass}ID\" IS NOT NULL)";
  261.                 }
  262.                 return clone $query;
  263.         }
  264. diff --git a/dataobject_manager/code/ManyManyFileDataObjectManager.php b/dataobject_manager/code/ManyManyFileDataObjectManager.php
  265. index 7aa480a..132207b 100644
  266. --- a/dataobject_manager/code/ManyManyFileDataObjectManager.php
  267. +++ b/dataobject_manager/code/ManyManyFileDataObjectManager.php
  268. @@ -56,7 +56,7 @@ class ManyManyFileDataObjectManager extends HasManyFileDataObjectManager
  269.                         $sourceField = 'Child';
  270.                 $parentID = $this->controller->ID;
  271.                
  272. -               $this->sourceJoin .= " LEFT JOIN `$manyManyTable` ON (`$source`.`ID` = `{$sourceField}ID` AND `$manyManyTable`.`{$this->manyManyParentClass}ID` = '$parentID')";
  273. +               $this->sourceJoin .= " LEFT JOIN \"$manyManyTable\" ON (\"$source\".\"ID\" = \"{$sourceField}ID\" AND \"$manyManyTable\".\"{$this->manyManyParentClass}ID\" = '$parentID')";
  274.                
  275.                 $this->joinField = 'Checked';
  276.                 if(isset($_REQUEST['ctf'][$this->Name()]['only_related']))
  277. @@ -77,28 +77,27 @@ class ManyManyFileDataObjectManager extends HasManyFileDataObjectManager
  278.         }
  279.        
  280.                
  281. -       protected function loadSort()
  282. -       {
  283. +       protected function loadSort() {
  284.  
  285.                 if($this->ShowAll())
  286.                         $this->setPageSize(999);
  287.  
  288. -    if(SortableDataObject::is_sortable_many_many($this->sourceClass(), $this->manyManyParentClass)) {
  289. -      list($parentClass, $componentClass, $parentField, $componentField, $table) = singleton($this->controllerClass())->many_many($this->Name());
  290. -      $sort_column = "`$table`.SortOrder";
  291. -      if(!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == $sort_column) {
  292. -        $this->sort = $sort_column;
  293. -        $this->sourceSort = "$sort_column " . SortableDataObject::$sort_dir;
  294. -      }
  295. -    }
  296. -              
  297. -               elseif($this->Sortable() && (!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == "SortOrder")) {
  298. +               $original_sort = $this->sourceSort;
  299. +       if (SortableDataObject::is_sortable_many_many($this->sourceClass(), $this->manyManyParentClass)) {
  300. +                       list($parentClass, $componentClass, $parentField, $componentField, $table) = singleton($this->controllerClass())->many_many($this->Name());
  301. +                       $sort_column = "$table.SortOrder";
  302. +                       if (!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == $sort_column) {
  303. +                               $this->sort = $sort_column;
  304. +                               $this->sourceSort = "\"$table\".\"SortOrder\" " . SortableDataObject::$sort_dir;
  305. +                       }
  306. +               } elseif ($this->Sortable() && (!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == "SortOrder")) {
  307.                         $this->sort = "SortOrder";
  308. -                       $this->sourceSort = "SortOrder " . SortableDataObject::$sort_dir;
  309. +                       $this->sourceSort = "\"SortOrder\" " . SortableDataObject::$sort_dir;
  310. +               } elseif (isset($_REQUEST['ctf'][$this->Name()]['sort'])) {
  311. +                       $this->sourceSort = "\"" . $_REQUEST['ctf'][$this->Name()]['sort'] . "\" " . $this->sort_dir;
  312.                 }
  313.                
  314. -               elseif(isset($_REQUEST['ctf'][$this->Name()]['sort']))
  315. -                       $this->sourceSort = $_REQUEST['ctf'][$this->Name()]['sort'] . " " . $this->sort_dir;
  316. +               if ($original_sort && $original_sort != $this->sourceSort) $this->sourceSort .= ', '.$original_sort;
  317.         }
  318.        
  319.        
  320. @@ -133,9 +132,9 @@ class ManyManyFileDataObjectManager extends HasManyFileDataObjectManager
  321.         function getQuery($limitClause = null) {
  322.                 if($this->customQuery) {
  323.                         $query = $this->customQuery;
  324. -                       $query->select[] = "{$this->sourceClass}.ID AS ID";
  325. -                       $query->select[] = "{$this->sourceClass}.ClassName AS ClassName";
  326. -                       $query->select[] = "{$this->sourceClass}.ClassName AS RecordClassName";
  327. +                       $query->select[] = "\"{$this->sourceClass}\".\"ID\" AS \"ID\"";
  328. +                       $query->select[] = "\"{$this->sourceClass}\".\"ClassName\" AS \"ClassName\"";
  329. +                       $query->select[] = "\"{$this->sourceClass}\".\"ClassName\" AS \"RecordClassName\"";
  330.                 }
  331.                 else {
  332.                         $query = singleton($this->sourceClass)->extendedSQL($this->sourceFilter, $this->sourceSort, $limitClause, $this->sourceJoin);
  333. @@ -144,16 +143,21 @@ class ManyManyFileDataObjectManager extends HasManyFileDataObjectManager
  334.  
  335.                         $SNG = singleton($this->sourceClass);
  336.                         foreach($this->FieldList() as $k => $title) {
  337. -                               if(! $SNG->hasField($k) && ! $SNG->hasMethod('get' . $k))
  338. +                               if(! $SNG->hasField($k) && ! $SNG->hasMethod('get' . $k)) {
  339.                                         $query->select[] = $k;
  340. +                                       // everything we add to select must be added to groupby too...
  341. +                                       $query->groupby[] = $k;
  342. +                               }
  343.                         }
  344.                         $parent = $this->controllerClass();
  345.                         $mm = $this->manyManyTable;
  346. -                       $if_clause = "IF(`$mm`.`{$this->manyManyParentClass}ID` IS NULL, '0', '1')";
  347. -                       $query->select[] = "$if_clause AS Checked";
  348. +                       $when_clause = "CASE WHEN \"$mm\".\"{$this->manyManyParentClass}ID\" IS NULL THEN '0' ELSE '1' END";
  349. +                       $query->select[] = "$when_clause AS \"Checked\"";
  350. +                       // everything we add to select must be added to groupby too...
  351. +                       $query->groupby[] = $when_clause;
  352.                        
  353.                         if($this->OnlyRelated())
  354. -                        $query->where[] = $if_clause;
  355. +                               $query->where[] = "(\"$mm\".\"{$this->manyManyParentClass}ID\" IS NOT NULL)";
  356.                 }
  357.                 return clone $query;
  358.         }
  359. diff --git a/dataobject_manager/code/SortableDataObject.php b/dataobject_manager/code/SortableDataObject.php
  360. index 0393460..7366ad4 100644
  361. --- a/dataobject_manager/code/SortableDataObject.php
  362. +++ b/dataobject_manager/code/SortableDataObject.php
  363. @@ -99,13 +99,13 @@ class SortableDataObject extends DataObjectDecorator
  364.            if($sort_field) break;
  365.            foreach($join_tables as $join_table) {
  366.              if(stristr($from,$join_table)) {
  367. -              $sort_field = "`$join_table`.SortOrder";
  368. +              $sort_field = "\"$join_table\".\"SortOrder\"";
  369.                break;
  370.              }
  371.            }
  372.         }
  373.            }
  374. -          if(!$sort_field) $sort_field = "SortOrder";
  375. +          if(!$sort_field) $sort_field = "\"SortOrder\"";
  376.            
  377.            if(!$query->orderby || ($query->orderby == $this->owner->stat('default_sort')))
  378.              $query->orderby = "$sort_field " . self::$sort_dir;
  379. diff --git a/dataobject_manager/code/dropdown_fields/SimpleTreeDropdownField.php b/dataobject_manager/code/dropdown_fields/SimpleTreeDropdownField.php
  380. index 0d7cdfe..f0d93d5 100644
  381. --- a/dataobject_manager/code/dropdown_fields/SimpleTreeDropdownField.php
  382. +++ b/dataobject_manager/code/dropdown_fields/SimpleTreeDropdownField.php
  383. @@ -21,7 +21,7 @@ class SimpleTreeDropdownField extends HTMLDropdownField
  384.         {
  385.                 $options = array();
  386.                 $class = ($this->sourceClass == "SiteTree" || is_subclass_of($this->sourceClass, "SiteTree")) ? "SiteTree" : $this->sourceClass;
  387. -               if($children = DataObject::get($class, "ParentID = $parentID")) {
  388. +               if($children = DataObject::get($class, "\"ParentID\" = $parentID")) {
  389.                         foreach($children as $child) {
  390.                                 $indent="";
  391.                                 for($i=0;$i<$level;$i++) $indent .= "&nbsp;&nbsp;";
  392. diff --git a/dataobject_manager/code/flv/FLV.php b/dataobject_manager/code/flv/FLV.php
  393. index 93afedd..7aca3fa 100644
  394. --- a/dataobject_manager/code/flv/FLV.php
  395. +++ b/dataobject_manager/code/flv/FLV.php
  396. @@ -189,7 +189,7 @@ class FLV extends File
  397.        
  398.         public function getThumbnail()
  399.         {
  400. -        if($img = DataObject::get_one("Image","Title = 'flv_thumb_{$this->ID}'"))
  401. +        if($img = DataObject::get_one("Image","\"Title\" = 'flv_thumb_{$this->ID}'"))
  402.            return Director::fileExists($img->Filename) ? $img : false;
  403.          return false;
  404.         }
  405. @@ -209,7 +209,7 @@ class FLV extends File
  406.         private function createThumbnail()
  407.         {
  408.        $img_title = "flv_thumb_".$this->ID;
  409. -      if($existing = DataObject::get("Image","Title = '$img_title'")) {
  410. +      if($existing = DataObject::get("Image","\"Title\" = '$img_title'")) {
  411.          foreach($existing as $file) $file->delete();
  412.        }
  413.                         $folder = Folder::findOrMake(self::$thumbnail_folder);
clone this paste RAW Paste Data