2 回答
TA贡献1818条经验 获得超3个赞
这就是我修复它的方法:
$lines = gz文件($fileName);
<?php
class reader{
public $dbName;
public $fileName;
public function import($dbName, $fileName){
$serverName = "localhost";
$userName = "root";
$password = "";
$conn = new mysqli($serverName,$userName,$password,$dbName);
$temp = "";
$lines = gzfile($fileName);
foreach($lines as $key => $line ){
if(substr($line, 0, 2) == '--' || $line == '') continue;
$temp .= $line;
if(substr(trim($line), -1, 1) == ';'){
$conn->query($temp) or print('Error performing query \'<strong>' . $temp . '\': '. '<br /><br />');
$temp = "";}
}
echo "<script>alert('Database Imported')</script>";
}
}
$bestand = new reader();
# dbname | file name
$bestand->import("test", "testdb.sql.gz");
?>
TA贡献1790条经验 获得超9个赞
如果您允许 system() 您可以:
<?php system("gzip -dc < ".$file." | mysql -u $dbuser -p$dbpassword $dbname");
- 2 回答
- 0 关注
- 139 浏览
添加回答
举报