我有一个apphp_db_install($sql_dump_file)
从 db_dump.sql 文件安装 sql 数据库的函数,我收到一个错误:
SQLSTATE [42000]:语法错误或访问冲突:1065 查询为空
我已经尝试在干净的数据库中使用此功能。
我安装 SQL 的功能:
function apphp_db_install($sql_dump_file) {
global $error_mg;
global $username;
global $password;
global $database_prefix;
global $password_encryption;
global $db;
$sql_array = array();
$query = "";
// get sql dump content
$sql_dump = file($sql_dump_file);
// replace database prefix if exists
$sql_dump = str_ireplace('<DB_PREFIX>', $database_prefix, $sql_dump);
// disabling magic quotes at runtime
if(get_magic_quotes_runtime()){
function stripslashes_runtime(&$value){
$value = stripslashes($value);
}
array_walk_recursive($sql_dump, 'stripslashes_runtime');
}
// add ";" at the end of file
if(substr($sql_dump[count($sql_dump)-1], -1) != ";") { $sql_dump[count($sql_dump)-1] .= ";"; }
// replace username and password if exists
if(EI_USE_USERNAME_AND_PASWORD){
$sql_dump = str_ireplace("<USER_NAME>", $username, $sql_dump);
if(EI_USE_PASSWORD_ENCRYPTION){
if($password_encryption == "AES"){
$sql_dump = str_ireplace("<PASSWORD>", "AES_ENCRYPT('".$password."', '".EI_PASSWORD_ENCRYPTION_KEY."')", $sql_dump);
}else if($password_encryption == "MD5"){
$sql_dump = str_ireplace("<PASSWORD>", "MD5('".$password."')", $sql_dump);
}else{
$sql_dump = str_ireplace("<PASSWORD>", "AES_ENCRYPT('".$password."', '".EI_PASSWORD_ENCRYPTION_KEY."')", $sql_dump);
}
}else{
$sql_dump = str_ireplace("<PASSWORD>", "'".$password."'", $sql_dump);
}
}else{
$sql_dump = str_ireplace("<USER_NAME>", "", $sql_dump);
$sql_dump = str_ireplace("<PASSWORD>", "''", $sql_dump);
}
$sql_dump = str_ireplace("<ENCRYPTION_TYPE>", $password_encryption, $sql_dump);
狐的传说