File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -1070,17 +1070,19 @@ If you want to create a connection without selecting a database you can omit
10701070the database name::
10711071
10721072 $dsn = 'mysql://root:password@localhost/';
1073+ ConnectionManager::setConfig('setup', ['url' => $dsn]);
10731074
10741075You can now use your connection object to execute queries that create/modify
10751076databases. For example to create a database::
10761077
1078+ $connection = ConnectionManager::get('setup');
10771079 $connection->execute("CREATE DATABASE IF NOT EXISTS my_database");
10781080
10791081.. note ::
10801082
10811083 When creating a database it is a good idea to set the character set and
1082- collation parameters. If these values are missing, the database will set
1083- whatever system default values it uses.
1084+ collation parameters (e.g. `` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci ``).
1085+ If these values are missing, the database will set whatever system default values it uses.
10841086
10851087.. meta ::
10861088 :title lang=en: Database Basics
You can’t perform that action at this time.
0 commit comments