WP-Query-Builder/Database.php

52 lines
1.6 KiB
PHP
Raw Normal View History

2025-01-27 19:35:17 +01:00
<?php
namespace DatabaseHelper;
use DatabaseHelper\classes\Query;
2025-01-27 19:35:17 +01:00
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.
}
public static function makeQuery(TableBlueprint $table): QueryBuilder {
return new Query($table);
2025-01-27 19:35:17 +01:00
}
2025-01-28 16:53:37 +01:00
public static function makeDeletion(TableBlueprint $table): DeletionBuilder {
2025-01-28 16:53:37 +01:00
// TODO: Implement makeDeletion() method.
}
public static function makeInsertion(TableBlueprint $table): InsertionBuilder {
2025-01-27 19:35:17 +01:00
// TODO: Implement makeInsertion() method.
}
public static function makeUpdate(TableBlueprint $table): UpdateBuilder {
2025-01-27 19:35:17 +01:00
// TODO: Implement makeUpdate() method.
}
2025-02-03 14:31:13 +01:00
/**
* Adds the WordPress database prefix to table names if not already present.
* @param string ...$tableName Array of table names to process
* @return void
*/
2025-01-27 19:35:17 +01:00
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;
}
}