mysqli-> 准备创建表的问题 [英] mysqli->prepare issue with creating tables
本文介绍了mysqli-> 准备创建表的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 mysqli->prepare
创建一个表,但是在准备语句时出错.我的声明如下:
I'm trying to create a table with mysqli->prepare
, but get an error while preparing the statement.
My statement is as follows:
$mysqli->prepare("CREATE TABLE ? (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY (id))");
然后我就将表名绑定到它
Then I just bind the table name to it
$mysqli->bind_param("s", $some_name);
并执行它.
$mysqli->execute();
我得到的错误是:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? (id INT AUTO_INCREMENT NOT NULL, PRIMARY KE' at line 1
你能帮我吗?
推荐答案
查看http://php.net/manual/en/mysqli-stmt.prepare.php
一般而言,参数仅在数据操作语言 (DML) 语句中合法,在数据定义语言 (DDL) 语句中无效.
In general, parameters are legal only in Data Manipulation Language (DML) statements, and not in Data Definition Language (DDL) statements.
这篇关于mysqli-> 准备创建表的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文