[php] dumps import by tables

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?
$DB_NAME = "ru1cbit4_test";
$DB_LOGIN = "root";
$DB_PASS = "";
//$link = mysqli_connect("localhost",$DB_LOGIN,$DB_PASS,$DB_NAME) or die("Error " . mysqli_error($link));
$dir = "/home/nvadim/dumps/portal06042015";
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
//echo $file . PHP_EOL; sleep(1);
if($file=="." || $file=="..") continue;
exec("mysql -uroot -ppassword ru1cbit4_test < $dir/$file", $out);
echo "файл: $file" . "\n";
}
closedir($dh);
}