PodsData::table_create PHP Method

table_create() public static method

Create a Table
Since: 2.0
public static table_create ( string $table, string $fields, boolean $if_not_exists = false ) : array | boolean | mixed | null | void
$table string Table name
$fields string
$if_not_exists boolean Check if the table exists.
return array | boolean | mixed | null | void
    public static function table_create($table, $fields, $if_not_exists = false)
    {
        /**
         * @var $wpdb wpdb
         */
        global $wpdb;
        $sql = "CREATE TABLE";
        if (true === $if_not_exists) {
            $sql .= " IF NOT EXISTS";
        }
        $sql .= " `{$wpdb->prefix}" . self::$prefix . "{$table}` ({$fields})";
        if (!empty($wpdb->charset)) {
            $sql .= " DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $sql .= " COLLATE {$wpdb->collate}";
        }
        return self::query($sql);
    }