意外输出 Dbdelta WordPress
Unexpected output Dbdelta WordPress
我在这里查看了许多与此问题相关的其他问题,但 none 到目前为止已经能够解决我的问题。
根据 dbDelta 上的法典。 SQL 语句必须:
You must put each field on its own line in your SQL statement.
You must have two spaces between the words PRIMARY KEY and the
definition of your primary key.
You must use the key word KEY rather than its synonym INDEX and you
must include at least one KEY.
You must not use any apostrophes or backticks around field names.
Field types must be all lowercase.
SQL keywords, like CREATE TABLE and UPDATE, must be uppercase.
我收到的错误消息是:
WordPress database error: [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 mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NUL' at line 1]
但在我看来,我的 SQL 声明符合 dbDelta 的要求。 NB 变量 $table_name 和 $charset_collate 在函数的前面定义。
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
statistics longblob NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
这个怎么样:
$sql = "CREATE TABLE " . $table_name. " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
statistics longblob NOT NULL,
PRIMARY KEY (id)
) " . $charset_collate . ";";
我在这里查看了许多与此问题相关的其他问题,但 none 到目前为止已经能够解决我的问题。
根据 dbDelta 上的法典。 SQL 语句必须:
You must put each field on its own line in your SQL statement.
You must have two spaces between the words PRIMARY KEY and the definition of your primary key.
You must use the key word KEY rather than its synonym INDEX and you must include at least one KEY.
You must not use any apostrophes or backticks around field names.
Field types must be all lowercase. SQL keywords, like CREATE TABLE and UPDATE, must be uppercase.
我收到的错误消息是:
WordPress database error: [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 mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NUL' at line 1]
但在我看来,我的 SQL 声明符合 dbDelta 的要求。 NB 变量 $table_name 和 $charset_collate 在函数的前面定义。
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
statistics longblob NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
这个怎么样:
$sql = "CREATE TABLE " . $table_name. " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
statistics longblob NOT NULL,
PRIMARY KEY (id)
) " . $charset_collate . ";";