[ad_1]
I’m trying to store the database table name as a const so I don’t have to write the below code every time:
$table_name = $wpdb -> prefix . 'name_here';
Instead, I’d like to do it like this:
define ( 'TABLE_NAME', 'wp_name_here' );
But when I use it to create the table, it won’t work…Why?
if ( $wpdb -> get_var ( $wpdb -> prepare ( "SHOW TABLES LIKE TABLE_NAME" ) ) !== TABLE_NAME ) {
$sql = "CREATE TABLE TABLE_NAME (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name tinytext NOT NULL,
value text NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
}
The table name now becomes TABLE_NAME if I use the above code.
