2025-01-27 19:35:17 +01:00
|
|
|
<?php
|
|
|
|
namespace DatabaseHelper;
|
|
|
|
|
|
|
|
use DatabaseHelper\interfaces\MigrationBlueprint;
|
|
|
|
use DatabaseHelper\interfaces\TableBlueprint;
|
2025-01-28 16:53:37 +01:00
|
|
|
use DatabaseHelper\interfaces\DeletionBuilder;
|
2025-01-27 19:35:17 +01:00
|
|
|
use DatabaseHelper\interfaces\UpdateBuilder;
|
2025-01-28 16:53:37 +01:00
|
|
|
use DatabaseHelper\interfaces\InsertionBuilder;
|
|
|
|
use DatabaseHelper\interfaces\QueryBuilder;
|
2025-01-27 19:35:17 +01:00
|
|
|
|
|
|
|
class Database implements interfaces\DatabaseHelper
|
|
|
|
{
|
2025-01-28 16:53:37 +01:00
|
|
|
public static function makeTable(string $tableName): TableBlueprint {
|
|
|
|
return new Table($tableName);
|
2025-01-27 19:35:17 +01:00
|
|
|
}
|
|
|
|
|
2025-01-28 16:53:37 +01:00
|
|
|
public static function makeMigration(TableBlueprint $table): MigrationBlueprint {
|
2025-01-27 19:35:17 +01:00
|
|
|
// TODO: Implement makeMigration() method.
|
|
|
|
}
|
|
|
|
|
2025-01-28 16:53:37 +01:00
|
|
|
public static function makeQuery(TableBlueprint ...$tables): QueryBuilder {
|
2025-01-27 19:35:17 +01:00
|
|
|
// TODO: Implement makeQuery() method.
|
|
|
|
}
|
|
|
|
|
2025-01-28 16:53:37 +01:00
|
|
|
|
|
|
|
public static function makeDeletion(TableBlueprint ...$tables): DeletionBuilder {
|
|
|
|
// TODO: Implement makeDeletion() method.
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function makeInsertion(TableBlueprint ...$tables): InsertionBuilder {
|
2025-01-27 19:35:17 +01:00
|
|
|
// TODO: Implement makeInsertion() method.
|
|
|
|
}
|
|
|
|
|
2025-01-28 16:53:37 +01:00
|
|
|
public static function makeUpdate(TableBlueprint ...$tables): UpdateBuilder {
|
2025-01-27 19:35:17 +01:00
|
|
|
// TODO: Implement makeUpdate() method.
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|