Code Duplication    Length = 32-32 lines in 2 locations

Alpha/Model/ActiveRecordProviderMySQL.php 1 location

@@ 1738-1769 (lines=32) @@
1735
     *
1736
     * @see Alpha\Model\ActiveRecordProviderInterface::checkTableExists()
1737
     */
1738
    public function checkTableExists($checkHistoryTable = false)
1739
    {
1740
        self::$logger->debug('>>checkTableExists(checkHistoryTable=['.$checkHistoryTable.'])');
1741
1742
        $config = ConfigProvider::getInstance();
1743
1744
        $tableExists = false;
1745
1746
        $sqlQuery = 'SHOW TABLES;';
1747
        $this->BO->setLastQuery($sqlQuery);
1748
1749
        $result = self::getConnection()->query($sqlQuery);
1750
1751
        if ($result) {
1752
            $tableName = ($checkHistoryTable ? $this->BO->getTableName().'_history' : $this->BO->getTableName());
1753
1754
            while ($row = $result->fetch_array(MYSQLI_NUM)) {
1755
                if (strtolower($row[0]) == mb_strtolower($tableName)) {
1756
                    $tableExists = true;
1757
                }
1758
            }
1759
1760
            self::$logger->debug('<<checkTableExists ['.$tableExists.']');
1761
1762
            return $tableExists;
1763
        } else {
1764
            throw new AlphaException('Failed to access the system database correctly, error is ['.self::getConnection()->error.']');
1765
            self::$logger->debug('<<checkTableExists [false]');
1766
1767
            return false;
1768
        }
1769
    }
1770
1771
    /**
1772
     * (non-PHPdoc).

Alpha/Model/ActiveRecordProviderSQLite.php 1 location

@@ 1753-1784 (lines=32) @@
1750
     *
1751
     * @see Alpha\Model\ActiveRecordProviderInterface::checkTableExists()
1752
     */
1753
    public function checkTableExists($checkHistoryTable = false)
1754
    {
1755
        self::$logger->debug('>>checkTableExists(checkHistoryTable=['.$checkHistoryTable.'])');
1756
1757
        $config = ConfigProvider::getInstance();
1758
1759
        $tableExists = false;
1760
1761
        $sqlQuery = 'SELECT name FROM sqlite_master WHERE type = "table";';
1762
        $this->BO->setLastQuery($sqlQuery);
1763
1764
        $result = self::getConnection()->query($sqlQuery);
1765
1766
        $tableName = ($checkHistoryTable ? $this->BO->getTableName().'_history' : $this->BO->getTableName());
1767
1768
        while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
1769
            if (strtolower($row['name']) == mb_strtolower($tableName)) {
1770
                $tableExists = true;
1771
            }
1772
        }
1773
1774
        if ($result) {
1775
            self::$logger->debug('<<checkTableExists ['.$tableExists.']');
1776
1777
            return $tableExists;
1778
        } else {
1779
            throw new AlphaException('Failed to access the system database correctly, error is ['.self::getLastDatabaseError().']');
1780
            self::$logger->debug('<<checkTableExists [false]');
1781
1782
            return false;
1783
        }
1784
    }
1785
1786
    /**
1787
     * (non-PHPdoc).