/** * @return array */ protected function tables() { if (!isset($this->_tables)) { $this->_tables = array_keys($this->db->admin_get_tables()); } return $this->_tables; }
/** * Recursively delete cache directory and truncate all DB tables prefixed with 'cf_' */ protected function forceFlushCoreFileAndDatabaseCaches() { // Delete typo3temp/Cache GeneralUtility::rmdir(PATH_site . 'typo3temp/Cache', TRUE); // Get all table names starting with 'cf_' and truncate them $tables = $this->databaseConnection->admin_get_tables(); foreach ($tables as $table) { $tableName = $table['Name']; if (substr($tableName, 0, 3) === 'cf_') { $this->databaseConnection->exec_TRUNCATEquery($tableName); } } }
/** * Returns TRUE if upgrade wizard for legacy EXT:eu_ldap records should be run. * * @return bool */ protected function checkEuLdap() { $table = 'tx_euldap_server'; $migrationField = 'tx_igldapssoauth_migrated'; // We check the database table itself and not whether EXT:eu_ldap is loaded // because it may have been deactivated since it is not incompatible $existingTables = $this->databaseConnection->admin_get_tables(); if (!isset($existingTables[$table])) { return FALSE; } // Ensure the column used to flag processed records is present $fields = $this->databaseConnection->admin_get_fields($table); if (!isset($fields[$migrationField])) { $alterTableQuery = 'ALTER TABLE ' . $table . ' ADD ' . $migrationField . ' tinyint(4) NOT NULL default \'0\''; // Method admin_query() will parse the query and make it compatible with DBAL, if needed $this->databaseConnection->admin_query($alterTableQuery); } $euLdapConfigurationRecords = $this->databaseConnection->exec_SELECTcountRows('*', $table, $migrationField . '=0'); return $euLdapConfigurationRecords > 0; }
/** * Returns list of available databases (with access-check based on username/password) * * @param bool $initialInstallation TRUE if first installation is in progress, FALSE if upgrading or usual access * @return array List of available databases */ protected function getDatabaseList($initialInstallation) { $this->initializeDatabaseConnection(); $databaseArray = $this->databaseConnection->admin_get_dbs(); // Remove mysql organizational tables from database list $reservedDatabaseNames = array('mysql', 'information_schema', 'performance_schema'); $allPossibleDatabases = array_diff($databaseArray, $reservedDatabaseNames); // If we are upgrading we show *all* databases the user has access to if ($initialInstallation === false) { return $allPossibleDatabases; } else { // In first installation we show all databases but disable not empty ones (with tables) $databases = array(); foreach ($allPossibleDatabases as $database) { $this->databaseConnection->setDatabaseName($database); $this->databaseConnection->sql_select_db(); $existingTables = $this->databaseConnection->admin_get_tables(); $databases[] = array('name' => $database, 'tables' => count($existingTables)); } return $databases; } }
/** * Rename a DB table * * @param string $oldTableName old table name * @param string $newTableName new table name * @return boolean */ protected function renameDatabaseTable($oldTableName, $newTableName) { $title = 'Renaming "' . $oldTableName . '" to "' . $newTableName . '" '; $tables = $this->databaseConnection->admin_get_tables(); if (isset($tables[$newTableName])) { $message = 'Table ' . $newTableName . ' already exists'; $status = FlashMessage::OK; } elseif (!isset($tables[$oldTableName])) { $message = 'Table ' . $oldTableName . ' does not exist'; $status = FlashMessage::ERROR; } else { $sql = 'RENAME TABLE ' . $oldTableName . ' TO ' . $newTableName . ';'; if ($this->databaseConnection->admin_query($sql) === false) { $message = ' SQL ERROR: ' . $this->databaseConnection->sql_error(); $status = FlashMessage::ERROR; } else { $message = 'OK!'; $status = FlashMessage::OK; } } $this->messageArray[] = array($status, $title, $message); return $status; }
/** * Tests if a given table exists in current default database * * @param string $tablename Table name for which to check whether it exists * @param array $info Additional info, will be displayed as debug message, if a key "message" exists this will be appended to the error message */ public static function tableExists($tablename, array $info = array()) { self::initializeDbObj(); $tables = self::$dbObj->admin_get_tables(); return self::isArrayKey($tablename, $tables, $info); }
/** * check if given table exists in current database * we can't check TCA or for installed extensions because dam and dam_ttcontent are not available for TYPO3 6.2 * * @param $table * @return bool */ protected function isTableAvailable($table) { $tables = $this->database->admin_get_tables(); return array_key_exists($table, $tables); }
protected function hasOldCacheTables() { $tables = $this->databaseConnection->admin_get_tables(); return isset($tables['tx_realurl_pathcache']) || isset($tables['tx_realurl_urlcache']); }
/** * Called by the extension manager to determine if the update menu entry * should by showed. * * @return bool */ public function access() { return array_key_exists($this->transferTable, $this->databaseConnection->admin_get_tables()); }
/** * @test * * @return void */ public function adminGetTablesReturnAllTablesFromDatabase() { $result = $this->subject->admin_get_tables(); $this->assertArrayHasKey('tt_content', $result); $this->assertArrayHasKey('pages', $result); }