直接上代码
假设我们要创建一张表用来作为wordpress网站的工单专用的table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | $table_ticket_name = $wpdb->prefix . "tickets"; $table_ticket_sql = "CREATE TABLE $table_ticket_name ( id int(11) NOT NULL auto_increment, user_id int(11) NOT NULL, type int(1) NOT NULL, number varchar(50) NOT NULL, email varchar(200), status int(1) default 0 NOT NULL, score int(1), note text NOT NULL, create_time datetime, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta($table_ticket_sql); |
原文链接:https://xiaohost.com/11545.html,转载请注明出处。