WowPress-Tailwind/theme/wowpress/Database/CreateTable.php

33 lines
713 B
PHP
Raw Normal View History

2024-04-15 16:00:49 +02:00
<?php
namespace WoWPress\Database;
class CreateTable
{
public static $table_name = "_tblname";
public static $own_prefix = "wowpress_";
public static $fields = [];
public static function sql()
{
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$table_name = $wpdb->prefix . static::$own_prefix . static::$table_name;
$sql = "CREATE TABLE $table_name (
ID mediumint(9) NOT NULL AUTO_INCREMENT,
";
foreach(static::$fields as $field => $options){
$sql .= $field." ".$options.",
";
}
$sql .= "PRIMARY KEY (ID)
) $charset_collate;";
return $sql;
}
}