| @@ 1741-1772 (lines=32) @@ | ||
| 1738 | * |
|
| 1739 | * @see Alpha\Model\ActiveRecordProviderInterface::checkTableExists() |
|
| 1740 | */ |
|
| 1741 | public function checkTableExists($checkHistoryTable = false) |
|
| 1742 | { |
|
| 1743 | self::$logger->debug('>>checkTableExists(checkHistoryTable=['.$checkHistoryTable.'])'); |
|
| 1744 | ||
| 1745 | $config = ConfigProvider::getInstance(); |
|
| 1746 | ||
| 1747 | $tableExists = false; |
|
| 1748 | ||
| 1749 | $sqlQuery = 'SHOW TABLES;'; |
|
| 1750 | $this->BO->setLastQuery($sqlQuery); |
|
| 1751 | ||
| 1752 | $result = self::getConnection()->query($sqlQuery); |
|
| 1753 | ||
| 1754 | if ($result) { |
|
| 1755 | $tableName = ($checkHistoryTable ? $this->BO->getTableName().'_history' : $this->BO->getTableName()); |
|
| 1756 | ||
| 1757 | while ($row = $result->fetch_array(MYSQLI_NUM)) { |
|
| 1758 | if (strtolower($row[0]) == mb_strtolower($tableName)) { |
|
| 1759 | $tableExists = true; |
|
| 1760 | } |
|
| 1761 | } |
|
| 1762 | ||
| 1763 | self::$logger->debug('<<checkTableExists ['.$tableExists.']'); |
|
| 1764 | ||
| 1765 | return $tableExists; |
|
| 1766 | } else { |
|
| 1767 | throw new AlphaException('Failed to access the system database correctly, error is ['.self::getConnection()->error.']'); |
|
| 1768 | self::$logger->debug('<<checkTableExists [false]'); |
|
| 1769 | ||
| 1770 | return false; |
|
| 1771 | } |
|
| 1772 | } |
|
| 1773 | ||
| 1774 | /** |
|
| 1775 | * (non-PHPdoc). |
|
| @@ 1713-1742 (lines=30) @@ | ||
| 1710 | * |
|
| 1711 | * @see Alpha\Model\ActiveRecordProviderInterface::checkTableExists() |
|
| 1712 | */ |
|
| 1713 | public function checkTableExists($checkHistoryTable = false) |
|
| 1714 | { |
|
| 1715 | self::$logger->debug('>>checkTableExists(checkHistoryTable=['.$checkHistoryTable.'])'); |
|
| 1716 | ||
| 1717 | $config = ConfigProvider::getInstance(); |
|
| 1718 | ||
| 1719 | $tableExists = false; |
|
| 1720 | ||
| 1721 | $sqlQuery = 'SELECT name FROM sqlite_master WHERE type = "table";'; |
|
| 1722 | $this->BO->setLastQuery($sqlQuery); |
|
| 1723 | ||
| 1724 | $result = self::getConnection()->query($sqlQuery); |
|
| 1725 | ||
| 1726 | $tableName = ($checkHistoryTable ? $this->BO->getTableName().'_history' : $this->BO->getTableName()); |
|
| 1727 | ||
| 1728 | while ($row = $result->fetchArray(SQLITE3_ASSOC)) { |
|
| 1729 | if (strtolower($row['name']) == mb_strtolower($tableName)) { |
|
| 1730 | $tableExists = true; |
|
| 1731 | } |
|
| 1732 | } |
|
| 1733 | ||
| 1734 | if ($result) { |
|
| 1735 | self::$logger->debug('<<checkTableExists ['.$tableExists.']'); |
|
| 1736 | ||
| 1737 | return $tableExists; |
|
| 1738 | } else { |
|
| 1739 | self::$logger->debug('<<checkTableExists'); |
|
| 1740 | throw new AlphaException('Failed to access the system database correctly, error is ['.self::getLastDatabaseError().']'); |
|
| 1741 | } |
|
| 1742 | } |
|
| 1743 | ||
| 1744 | /** |
|
| 1745 | * (non-PHPdoc). |
|