use `PreparedStatement#fechSingleColumn` where possible
authorjens1o <jenshausdorf@gmail.com>
Sat, 11 Nov 2017 09:54:32 +0000 (10:54 +0100)
committerjens1o <jenshausdorf@gmail.com>
Sat, 11 Nov 2017 09:54:32 +0000 (10:54 +0100)
23 files changed:
wcfsetup/install/files/lib/acp/form/DevtoolsProjectAddForm.class.php
wcfsetup/install/files/lib/acp/form/DevtoolsProjectEditForm.class.php
wcfsetup/install/files/lib/acp/page/UserListPage.class.php
wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php
wcfsetup/install/files/lib/data/ad/AdEditor.class.php
wcfsetup/install/files/lib/data/label/LabelEditor.class.php
wcfsetup/install/files/lib/data/like/LikeAction.class.php
wcfsetup/install/files/lib/data/notice/NoticeEditor.class.php
wcfsetup/install/files/lib/data/page/PageEditor.class.php
wcfsetup/install/files/lib/data/paid/subscription/PaidSubscriptionEditor.class.php
wcfsetup/install/files/lib/data/user/authentication/failure/UserAuthenticationFailure.class.php
wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php
wcfsetup/install/files/lib/system/box/BoxHandler.class.php
wcfsetup/install/files/lib/system/cli/command/ImportCLICommand.class.php
wcfsetup/install/files/lib/system/language/LanguageFactory.class.php
wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueReportManager.class.php
wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/stat/AbstractCommentStatDailyHandler.class.php
wcfsetup/install/files/lib/system/stat/AbstractDiskUsageStatDailyHandler.class.php
wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php
wcfsetup/install/files/lib/system/stat/LikeStatDailyHandler.class.php
wcfsetup/install/files/lib/system/version/VersionTracker.class.php
wcfsetup/install/files/lib/system/worker/StatDailyRebuildDataWorker.class.php

index b42e41ba6b6978e46fc613a19846392097d57f89..e3bdcbf8dd955237a7360051b3fdd83f2d94302f 100644 (file)
@@ -96,7 +96,7 @@ class DevtoolsProjectAddForm extends AbstractForm {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->name]);
                
-               if ($statement->fetchColumn()) {
+               if ($statement->fetchSingleColumn()) {
                        throw new UserInputException('name', 'notUnique');
                }
        }
@@ -111,7 +111,7 @@ class DevtoolsProjectAddForm extends AbstractForm {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->path]);
                
-               if ($statement->fetchColumn()) {
+               if ($statement->fetchSingleColumn()) {
                        throw new UserInputException('path', 'notUnique');
                }
        }
index 8d6a685df381335be6120628cc2378e37cda8b9e..66a019653d77ad2789b962404aa64194b9c23679 100644 (file)
@@ -59,7 +59,7 @@ class DevtoolsProjectEditForm extends DevtoolsProjectAddForm {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->name, $this->objectID]);
                
-               if ($statement->fetchColumn()) {
+               if ($statement->fetchSingleColumn()) {
                        throw new UserInputException('name', 'notUnique');
                }
        }
@@ -76,7 +76,7 @@ class DevtoolsProjectEditForm extends DevtoolsProjectAddForm {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->path, $this->objectID]);
                
-               if ($statement->fetchColumn()) {
+               if ($statement->fetchSingleColumn()) {
                        throw new UserInputException('path', 'notUnique');
                }
        }
index 83e2df27250bb19613614a699665ec09f490c38a..86d8bafaa2839f78db436f90a8c84c6a70228bfc 100755 (executable)
@@ -224,7 +224,7 @@ class UserListPage extends SortablePage {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($this->conditions->getParameters());
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
        
        /**
index f35b3ac9b475938d4417092bbb6112748215a4d0..c57eb3ce001fa0a67d3ec0169a2d82d1207f9b03 100644 (file)
@@ -65,6 +65,6 @@ class ACPSessionVirtual extends DatabaseObject {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$sessionID]);
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
 }
index d89d5d75eb5e980ffbd9c4f00fe84c2f61146c2b..6b726c68cd0fc00eb0974244e710e1e743932b1e 100644 (file)
@@ -35,7 +35,7 @@ class AdEditor extends DatabaseObjectEditor implements IEditableCachedObject {
                        FROM    wcf".WCF_N."_ad";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               $maxShowOrder = $statement->fetchColumn();
+               $maxShowOrder = $statement->fetchSingleColumn();
                if (!$maxShowOrder) $maxShowOrder = 0;
                
                if (!$showOrder || $showOrder > $maxShowOrder) {
index 59973d3fbe9135d0e0cbecd8a065182771a07dfa..6b9a9603ab9dade46a738814cba8dac6705933ae 100644 (file)
@@ -63,7 +63,7 @@ class LabelEditor extends DatabaseObjectEditor implements IEditableCachedObject
                        WHERE   groupID = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$groupID]);
-               $maxShowOrder = $statement->fetchColumn() ?: 0;
+               $maxShowOrder = $statement->fetchSingleColumn() ?: 0;
                
                if (!$showOrder || $showOrder > $maxShowOrder) {
                        $showOrder = $maxShowOrder + 1;
index bd041d7ee420b9efbf24975e0c7c3ec8e87c36c9..319afa64062657c251f69459dc825ca40f441398 100644 (file)
@@ -242,7 +242,7 @@ class LikeAction extends AbstractDatabaseObjectAction implements IGroupedUserLis
                        $this->parameters['data']['objectID'],
                        $this->objectType->objectTypeID
                ]);
-               $pageCount = ceil($statement->fetchColumn() / 20);
+               $pageCount = ceil($statement->fetchSingleColumn() / 20);
                
                $sql = "SELECT          userID, likeValue
                        FROM            wcf".WCF_N."_like
index 67efdeb48a7dbad158331b8b462eda96db38eb2e..3d35d322c44e2e7986c2790f4bf6361ba8b501e2 100644 (file)
@@ -35,7 +35,7 @@ class NoticeEditor extends DatabaseObjectEditor implements IEditableCachedObject
                        FROM    wcf".WCF_N."_notice";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               $maxShowOrder = $statement->fetchColumn();
+               $maxShowOrder = $statement->fetchSingleColumn();
                if (!$maxShowOrder) $maxShowOrder = 0;
                
                if (!$showOrder || $showOrder > $maxShowOrder) {
index 881dd8bebfb01a9782883ca6239506bc373041e5..7dfdd3f1b5b9aeed7316e253ef65aa4d6d6e43d1 100644 (file)
@@ -66,7 +66,7 @@ class PageEditor extends DatabaseObjectEditor implements IEditableCachedObject {
                                AND applicationPackageID = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$customURL, $packageID]);
-               if ($statement->fetchColumn()) {
+               if ($statement->fetchSingleColumn()) {
                        return false;
                }
                
@@ -81,7 +81,7 @@ class PageEditor extends DatabaseObjectEditor implements IEditableCachedObject {
                                )";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$customURL, $packageID]);
-               if ($statement->fetchColumn()) {
+               if ($statement->fetchSingleColumn()) {
                        return false;
                }
                
index 967aeba75f336150d7d5b49b08f1415dd9014e37..b845066b1b6507e90a6aae2144e34aa700c193db 100644 (file)
@@ -33,7 +33,7 @@ class PaidSubscriptionEditor extends DatabaseObjectEditor implements IEditableCa
                        FROM    wcf".WCF_N."_paid_subscription";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               $maxShowOrder = $statement->fetchColumn();
+               $maxShowOrder = $statement->fetchSingleColumn();
                if (!$maxShowOrder) $maxShowOrder = 0;
                
                if (!$showOrder || $showOrder > $maxShowOrder) {
index 456021d4f7a8e8432e512a5690c25d4c0f4ecc80..f86ec0241362d045254bf2f52596e52930e8de47 100644 (file)
@@ -44,7 +44,7 @@ class UserAuthenticationFailure extends DatabaseObject {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$ipAddress, TIME_NOW - USER_AUTHENTICATION_FAILURE_TIMEOUT]);
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
        
        /**
@@ -61,6 +61,6 @@ class UserAuthenticationFailure extends DatabaseObject {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$userID, TIME_NOW - USER_AUTHENTICATION_FAILURE_TIMEOUT]);
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
 }
index 3e26d95414b315c142a2279a4238cc1620c08302..08d3922ed9ff8c9d219092c41f2ad2076fb94b1a 100644 (file)
@@ -127,8 +127,7 @@ class UserGroupEditor extends DatabaseObjectEditor implements IEditableCachedObj
                        WHERE   optionName = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(['admin.user.accessibleGroups']);
-               $optionID = $statement->fetchColumn();
-               $statement->closeCursor();
+               $optionID = $statement->fetchSingleColumn();
                
                if (!$optionID) throw new SystemException("Unable to find 'admin.user.accessibleGroups' user option");
                
index 27d6a8b53de3fe7ea8f2cb2e67e656298ba8548b..4fb95c7c27770070cf414ff12cd6ff99b9c2c056 100644 (file)
@@ -280,6 +280,6 @@ class BoxHandler extends SingletonFactory {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$pageID]);
                
-               return $statement->fetchColumn() > 0;
+               return $statement->fetchSingleColumn() > 0;
        }
 }
index 8ddc5e071b63aa20dece49a4e5e6e311cd86ff9a..4329155473700706c0301f95e2c1a9bf0011a04c 100644 (file)
@@ -139,7 +139,7 @@ class ImportCLICommand implements ICLICommand {
                        FROM    wcf".WCF_N."_import_mapping";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               if ($statement->fetchColumn()) {
+               if ($statement->fetchSingleColumn()) {
                        CLIWCF::getReader()->println(StringUtil::stripHTML(WCF::getLanguage()->get('wcf.acp.dataImport.existingMapping.notice')));
                        CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.existingMapping.confirmMessage') . ' [YN]');
                        
index 18919304c980cd1a2b4f7e41067bc352b6347714..8500e10428d49429f6e3d15cc58210c09ea00936 100644 (file)
@@ -354,6 +354,6 @@ class LanguageFactory extends SingletonFactory {
                $statement = WCF::getDB()->prepareStatement($sql, 1);
                $statement->execute([TIME_NOW - 86400 * 7]);
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
 }
index 2192a6f9841495bc4514c911fafea61708e1566c..a2992c606d7a28f3f8e83c810b673bf87a8ade03 100644 (file)
@@ -68,7 +68,7 @@ class ModerationQueueReportManager extends AbstractModerationQueueManager {
                        ModerationQueue::STATUS_PROCESSING
                ]);
                
-               return $statement->fetchColumn() > 0;
+               return $statement->fetchSingleColumn() > 0;
        }
        
        /**
index bcb2c627a123b4cea2211f811db13a0e78667b6b..d29f080f1c1987ebfbb809b6ecb811f4cb0fec2e 100644 (file)
@@ -271,7 +271,7 @@ class ACLOptionPackageInstallationPlugin extends AbstractOptionPackageInstallati
                                        )";
                        $statement = WCF::getDB()->prepareStatement($sql, 1);
                        $statement->execute([$optionType]);
-                       $objectTypeID = $statement->fetchColumn();
+                       $objectTypeID = $statement->fetchSingleColumn();
                        if ($objectTypeID === false) {
                                throw new SystemException("unknown object type '".$optionType."' given");
                        }
index 2c0258dab31d3fe45078c900862fbd4225e20824..d8378f66779d99bb86024d6e5b99101515b576a0 100644 (file)
@@ -51,7 +51,7 @@ abstract class AbstractCommentStatDailyHandler extends AbstractStatDailyHandler
                        $date,
                        $date + 86399
                ]);
-               $counter = $statement->fetchColumn();
+               $counter = $statement->fetchSingleColumn();
                
                $sql = "SELECT (
                                SELECT  COUNT(*)
@@ -73,7 +73,7 @@ abstract class AbstractCommentStatDailyHandler extends AbstractStatDailyHandler
                        $objectTypeID,
                        $date + 86400
                ]);
-               $total = $statement->fetchColumn();
+               $total = $statement->fetchSingleColumn();
                
                return [
                        'counter' => $counter,
index b9289055d5627465cd769be08607b086995f405e..eecab94717526b7195072c200b56535066d075c7 100644 (file)
@@ -34,7 +34,7 @@ abstract class AbstractDiskUsageStatDailyHandler extends AbstractStatDailyHandle
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditionBuilder->getParameters());
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
        
        /**
@@ -52,7 +52,7 @@ abstract class AbstractDiskUsageStatDailyHandler extends AbstractStatDailyHandle
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditionBuilder->getParameters());
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
        
        /**
index 7581ea66a299836742a35806cfdd6285c9e30e40..547c87aec1d16dd7ce1c6e0e3096cf5d045219d9 100644 (file)
@@ -32,7 +32,7 @@ abstract class AbstractStatDailyHandler implements IStatDailyHandler {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditionBuilder->getParameters());
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
        
        /**
@@ -55,7 +55,7 @@ abstract class AbstractStatDailyHandler implements IStatDailyHandler {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditionBuilder->getParameters());
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
        
        /**
index b4c0bd0a6a7990726a3666e34d53b918362cb4e0..292cc5cc133fd72b8795183b32a68fd29cb16bf9 100644 (file)
@@ -24,7 +24,7 @@ class LikeStatDailyHandler extends AbstractStatDailyHandler {
                                AND likeValue = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$date, $date + 86399, $this->likeValue]);
-               $counter = intval($statement->fetchColumn());
+               $counter = intval($statement->fetchSingleColumn());
                
                $sql = "SELECT  COUNT(*)
                        FROM    wcf".WCF_N."_like
@@ -32,7 +32,7 @@ class LikeStatDailyHandler extends AbstractStatDailyHandler {
                                AND likeValue = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$date + 86400, $this->likeValue]);
-               $total = intval($statement->fetchColumn());
+               $total = intval($statement->fetchSingleColumn());
                
                return [
                        'counter' => $counter,
index b372d667cd6c1712c3fcc99e108bf6912949f545..e146b08967c2dfa4475fbc7cacc1d8ee6a6515ac 100644 (file)
@@ -105,7 +105,7 @@ class VersionTracker extends SingletonFactory implements IAJAXInvokeAction {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$objectID]);
                
-               return $statement->fetchColumn();
+               return $statement->fetchSingleColumn();
        }
        
        /**
index 79d9abf1c5ce3b2119394ab2d4d4ff9660b93bf4..81e0802b8e4ad569fc2d141082a9fcfcdac668cf 100644 (file)
@@ -90,6 +90,6 @@ class StatDailyRebuildDataWorker extends AbstractRebuildDataWorker {
                        FROM    wcf".WCF_N."_user";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               $this->startDate = $statement->fetchColumn();
+               $this->startDate = $statement->fetchSingleColumn();
        }
 }