我正在尝试通过这些语句添加新的数据库用户:
$insert = $db->prepare("CREATE USER ? IDENTIFIED BY ?");
$insert->bind_param('ss', $_POST['username'], $_POST['pass']);
$insert->execute();
数据库给了我错误:
You have an error in your SQL syntax; (...) near '? IDENTIFIED BY ?' at line 1
当我尝试添加没有?
通配符的新用户时,一切都很好:
CREATE USER john IDENTIFIED BY 'johnpassword' //this works
,
但即使CONCAT("'", ?, "'")
用于提交数据也无济于事。
我在 MySQL 文档中读到 MySQL 5.7 应该支持CREATE USER
SQL 语句的预准备语句,但 MySQLi 似乎不支持。