<div class="jb51code">
<pre class="brush:sql;">
//读取文件内容
$_sql = file_get_contents('test.sql');
$_arr = explode(';',$_sql);
$_mysqli = new mysqli(DB_HOST,DB_USER,DB_PASS);
if (mysqli_connect_errno()) {
exit('连接数据库出错');
}
//执行sql语句
foreach ($_arr as $_value) {
$_mysqli->query($value.';');
}
$MysqLi->close();
$_MysqLi = null;