php - source 命令无法使用?
本文介绍了php - source 命令无法使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
无法导入???
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 D:\Server\three\public\export.sql' at line 1
function ImportDB($dbh) {
$sql = 'source '.realpath('export.sql');
try {
$stmt = $dbh->prepare($sql);
var_dump($stmt->execute());
var_dump($stmt->errorInfo());
}
catch (PDOException $e) {
print $e->getMessage();
}
}
注:导入包没问题:
解决方案
execute()
只能执行SQL语句,而SOURCE
虽然也能在mysqlclient
中执行,但是并不是sql语句,所以d会执行失败,建议直接用php的exec
命令进行执行
这篇关于php - source 命令无法使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文