E
E
Evgenij Popov2021-06-13 11:53:22
WordPress
Evgenij Popov, 2021-06-13 11:53:22

Why do we need the line require_once(ABSPATH. 'wp-admin/includes/upgrade.php'); when updating wordpress sql table?

Hi
Why is this line in a piece of code
----------------------------------------
function update_table( ) {
global $wpdb;

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

$table_name = $wpdb->get_blog_prefix() . 'test_table';
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset} COLLATE {$wpdb->collate}";

$sql = "CREATE TABLE {$table_name} (
id bigint(20) unsigned NOT NULL auto_increment,
address varchar(255) NOT NULL default '',
alert varchar(20) NOT NULL default '',
meta longtext NOT NULL default '' ,
new_meta longtext NOT NULL default '',
PRIMARY KEY (id),
{$charset_collate};";

dbDelta($sql);
}

update_table();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question