39 lines
1018 B
PHP
39 lines
1018 B
PHP
<?php
|
|
namespace DatabaseHelper;
|
|
|
|
use DatabaseHelper\beans\Schema;
|
|
|
|
class Database
|
|
{
|
|
public static function makeTable(string $tableName): Table {
|
|
return new Table($tableName);
|
|
}
|
|
|
|
public static function makeMigration(Schema $table): Migration {
|
|
return new Migration($table);
|
|
}
|
|
public static function makeQuery(Schema $table): Query {
|
|
return new Query($table);
|
|
}
|
|
|
|
public static function makeDeletion(Schema $table): Deletion {
|
|
return new Deletion($table);
|
|
}
|
|
|
|
public static function makeInsertion(Schema $table): Insertion {
|
|
return new Insertion($table);
|
|
}
|
|
|
|
public static function makeUpdate(Schema $table): Update {
|
|
return new Update($table);
|
|
}
|
|
|
|
public static function standardizeTableNames(string &...$tableName): void {
|
|
global $wpdb;
|
|
$dbPrefix = $wpdb->prefix;
|
|
|
|
foreach ($tableName as &$name)
|
|
if (!str_starts_with($name, $dbPrefix))
|
|
$name = $dbPrefix . $name;
|
|
}
|
|
} |