Answer the question
In order to leave comments, you need to log in
How to throw the scheme from the dump into the created database?
Tell me how to fill the newly created database with a dump, or is there some other way?
there is a file with a dump, I create an empty database and I want to load the scheme. here is my way:
$dbName = 'ec'.$tenantCreate->id;
$query = sprintf(
"CREATE DATABASE IF NOT EXISTS %s CHARACTER SET %s COLLATE %s;",
$dbName,
$charset,
$collation
);
$result = $connection->statement($query);
if (!$result) {
throw new \Exception('Не создана база данных для аккаунта ' . $tenantCreate->id);
}
$query = sprintf(
"USE %s; SOURCE %s;",
$dbName,
__DIR__ . '/../../../../dump_scheme.sql'
);
$result = $connection->statement($query);
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SOURCE /var/www/app/Tenant/Infrastructure/Services/../../../../dump_sch' at line 1 (SQL: USE ec32; SOURCE /var/www/app/Tenant/Infrastructure/Services/../../../../dump_scheme.sql;)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question