Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 1d6561c

Browse files
committed
Add method to import an sql dump
1 parent 307c5ed commit 1d6561c

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/php/libsdk/SDK/Build/PGO/Server/MariaDB.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,31 @@ public function query(string $s, string $db = NULL) : void
114114
$port = $this->conf->getSectionItem($this->name, "port");
115115

116116
$pass_arg = $pass ? "-p$pass " : "";
117-
$ret = shell_exec(".\\bin\\mysql.exe -u $user $pass_arg -h $host -P $port -e \"$s\"");
117+
$db_arg = $db ? "-D $db" : "";
118+
$ret = shell_exec(".\\bin\\mysql.exe -u $user $pass_arg -h $host -P $port $db_arg -e \"$s\"");
118119
//var_dump($this->base, getcwd(), ".\\bin\\mysql.exe -u $user $pass_arg -h $host -P $port -e \"$s\"");
119120

120121
chdir($cwd);
121122
}
123+
124+
public function import(string $path, string $db = NULL) : void
125+
{
126+
$ret = NULL;
127+
128+
$cwd = getcwd();
129+
130+
chdir($this->base);
131+
132+
$user = $this->conf->getSectionItem($this->name, "user");
133+
$pass = $this->conf->getSectionItem($this->name, "pass");
134+
$host = $this->conf->getSectionItem($this->name, "host");
135+
$port = $this->conf->getSectionItem($this->name, "port");
136+
137+
$pass_arg = $pass ? "-p$pass " : "";
138+
$db_arg = $db ? "-D $db" : "";
139+
$ret = shell_exec(".\\bin\\mysql.exe -u $user $pass_arg -h $host -P $port $db_arg < \"$path\"");
140+
141+
chdir($cwd);
142+
}
122143
}
123144

0 commit comments

Comments
 (0)