I am trying to create a new database inside my class and I'm passing in '$this->table' to the 'createHousekeepingTable()' function and I can see the string is being passed successfully but the table does not create in the database? I have no errors.
I replaced the '$this->table' with a string as per the docs and it works fine. For some reason I cannot pass in the variable and make it work.
Any ideas why?
<?php
/*
* Housekeeping Log
* @since 1.0.0
*/
class Housekeeping
{
private $wpdb;
private $table;
public function __construct() {
global $wpdb;
$this->wpdb = $wpdb;
$this->table = $wpdb->prefix . 'dc_housekeeping';
}
public function createHousekeepingTable() {
add_action( 'init', 'housekeeping_create_table' );
function housekeeping_create_table() {
MB_Custom_Table_API::create( "{$this->table}", array(
'type' => 'VARCHAR(20) NOT NULL',
'date' => 'DATETIME NOT NULL',
'action_date' => 'DATETIME NOT NULL',
'log' => 'VARCHAR(255) NOT NULL'
) );
}
}
}
?>