WP-Query-Builder/Database.php
2025-02-05 12:29:49 +01:00

54 lines
1.6 KiB
PHP

<?php
namespace DatabaseHelper;
class Database
{
/**
* Creates a new TableBlueprint instance for the specified table name.
* @param string $tableName The name of the table to create.
* @return Table A blueprint instance representing the table.
*/
public static function makeTable(string $tableName): Table {
return new Table($tableName);
}
public static function makeMigration(Table $table): Migration {
// TODO: Implement makeMigration() method.
}
/**
* Creates a new QueryBuilder instance for the specified table.
* @param Table $table The table to query on.
* @return Query instance supporting method chaining.
*/
public static function makeQuery(Table $table): Query {
return new Query($table);
}
public static function makeDeletion(Table $table): Deletion {
// TODO: Implement makeDeletion() method.
}
public static function makeInsertion(Table $table): Insertion {
// TODO: Implement makeInsertion() method.
}
public static function makeUpdate(Table $table): Update {
// 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;
}
}