Added an option to disable the qualified shorthand in dbo list queries
authorMarcel Werk <burntime@woltlab.com>
Thu, 1 Mar 2012 20:26:02 +0000 (21:26 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 1 Mar 2012 20:26:02 +0000 (21:26 +0100)
wcfsetup/install/files/lib/data/DatabaseObjectList.class.php

index 4fdef16772194c5c461796dca9a8d39ef8139162..530becdad32b41311c2f2f3e0a01ba7c6a2f5aa0 100644 (file)
@@ -75,6 +75,12 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject {
         */
        public $sqlJoins = '';
        
+       /**
+        * enables the automatic usage of the qualified shorthand 
+        * @var boolean
+        */
+       public $useQualifiedShorthand = true;
+       
        /**
         * sql conditions
         * @var wcf\system\database\util\PreparedStatementConditionBuilder
@@ -142,8 +148,8 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject {
                                return;
                        }
                        
-                       $sql = "SELECT  ".(!empty($this->sqlSelects) ? $this->sqlSelects.',' : '')."
-                                       ".$this->getDatabaseTableAlias().".*
+                       $sql = "SELECT  ".(!empty($this->sqlSelects) ? $this->sqlSelects.($this->useQualifiedShorthand ? ',' : '') : '')."
+                                       ".($this->useQualifiedShorthand ? $this->getDatabaseTableAlias().'.*' : '')."
                                FROM    ".$this->getDatabaseTableName()." ".$this->getDatabaseTableAlias()."
                                        ".$this->sqlJoins."
                                WHERE   ".$this->getDatabaseTableAlias().".".$this->getDatabaseTableIndexName()." IN (?".str_repeat(',?', count($this->objectIDs) - 1).")
@@ -153,8 +159,8 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject {
                        $this->objects = $statement->fetchObjects(($this->objectClassName ?: $this->className));
                }
                else {
-                       $sql = "SELECT  ".(!empty($this->sqlSelects) ? $this->sqlSelects.',' : '')."
-                                       ".$this->getDatabaseTableAlias().".*
+                       $sql = "SELECT  ".(!empty($this->sqlSelects) ? $this->sqlSelects.($this->useQualifiedShorthand ? ',' : '') : '')."
+                                       ".($this->useQualifiedShorthand ? $this->getDatabaseTableAlias().'.*' : '')."
                                FROM    ".$this->getDatabaseTableName()." ".$this->getDatabaseTableAlias()."
                                        ".$this->sqlJoins."
                                        ".$this->getConditionBuilder()->__toString()."