maybe_create_table()
maybe_create_table( string $table_name, string $create_ddl )
在数据库中创建一个表(如果该表不存在)。
Creates a table in the database if it doesn’t already exist.
说明(Description)
此方法检查现有数据库,如果该数据库不存在,则创建一个新数据库。它不依赖MySQL的“IF NOT EXISTS”语句,而是选择先查询所有表,然后运行创建表的SQL语句。
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$table_name | (string) | 必需 | 要创建的数据库表名。 |
$create_ddl | (string) | 必需 | 创建表的SQL语句。 |
返回(Return)
(bool)如果表已经存在或是由函数创建的。
源码(Source)
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
1.0.0 | wp-admin/includes/upgrade.php:2328 | 0 | 5 |
笔记(Notes)
在调用此函数之前,必须手动包括’升级.php’否则你将以死亡的白屏结束。
maybe_create_table() 为WP2原创文章,链接:https://www.wp2.cn/functions/maybe_create_table/