WP-Query-Builder/Database.php
2025-02-03 17:44:52 +01:00

52 lines
1.6 KiB
PHP

<?php
namespace DatabaseHelper;
use DatabaseHelper\classes\Query;
use DatabaseHelper\interfaces\MigrationBlueprint;
use DatabaseHelper\interfaces\TableBlueprint;
use DatabaseHelper\interfaces\DeletionBuilder;
use DatabaseHelper\interfaces\UpdateBuilder;
use DatabaseHelper\interfaces\InsertionBuilder;
use DatabaseHelper\interfaces\QueryBuilder;
class Database implements interfaces\DatabaseHelper
{
public static function makeTable(string $tableName): TableBlueprint {
return new Table($tableName);
}
public static function makeMigration(TableBlueprint $table): MigrationBlueprint {
// TODO: Implement makeMigration() method.
}
public static function makeQuery(TableBlueprint $table): QueryBuilder {
return new Query($table);
}
public static function makeDeletion(TableBlueprint $table): DeletionBuilder {
// TODO: Implement makeDeletion() method.
}
public static function makeInsertion(TableBlueprint $table): InsertionBuilder {
// TODO: Implement makeInsertion() method.
}
public static function makeUpdate(TableBlueprint $table): UpdateBuilder {
// TODO: Implement makeUpdate() method.
}
/**
* Adds the WordPress database prefix to table names if not already present.
* @param string ...$tableName Array of table names to process
* @return void
*/
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;
}
}