WP-Database-Helper/Database.php

39 lines
1018 B
PHP
Raw Permalink Normal View History

2025-02-12 14:03:39 +00:00
<?php
namespace DatabaseHelper;
2025-02-21 18:06:16 +00:00
use DatabaseHelper\beans\Schema;
2025-02-12 14:03:39 +00:00
class Database
{
public static function makeTable(string $tableName): Table {
return new Table($tableName);
}
public static function makeMigration(Schema $table): Migration {
2025-02-24 09:54:51 +00:00
return new Migration($table);
2025-02-12 14:03:39 +00:00
}
public static function makeQuery(Schema $table): Query {
return new Query($table);
}
public static function makeDeletion(Schema $table): Deletion {
2025-02-24 09:54:51 +00:00
return new Deletion($table);
2025-02-12 14:03:39 +00:00
}
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;
}
}