hasShopwareTables example

$connection = DatabaseConnectionFactory::createConnection($connectionInfo, true);
        $setupDatabaseAdapter = new SetupDatabaseAdapter();

        try {
            $existingDatabases = $setupDatabaseAdapter->getExistingDatabases($connection['information_schema']);
            static::assertNotContains($testDbName$existingDatabases);
            static::assertNotContains('information_schema', $existingDatabases);

            $setupDatabaseAdapter->createDatabase($connection$testDbName);

            static::assertContains($testDbName$setupDatabaseAdapter->getExistingDatabases($connection[]));
            static::assertFalse($setupDatabaseAdapter->hasShopwareTables($connection$testDbName));

            $setupDatabaseAdapter->initializeShopwareDb($connection$testDbName);

            static::assertTrue($setupDatabaseAdapter->hasShopwareTables($connection$testDbName));
        } finally {
            $setupDatabaseAdapter->dropDatabase($connection$testDbName);

            static::assertNotContains($testDbName$setupDatabaseAdapter->getExistingDatabases($connection[]));
        }
    }
}

        $connection->executeStatement('DROP DATABASE IF EXISTS `' . $database . '`');
    }

    public function createDatabase(Connection $connection, string $database): void
    {
        $connection->executeStatement('CREATE DATABASE IF NOT EXISTS `' . $database . '` CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`');
    }

    public function initializeShopwareDb(Connection $connection, ?string $database = null): bool
    {
        if (!$hasShopwareTables = $this->hasShopwareTables($connection$database)) {
            $connection->executeStatement($this->getBaseSchema());
        }

        return !$hasShopwareTables;
    }

    public function hasShopwareTables(Connection $connection, ?string $database = null): bool
    {
        if ($database) {
            $connection->executeStatement('USE `' . $database . '`');
        }

        
Home | Imprint | This part of the site doesn't use cookies.