Finalize database interface
This commit is contained in:
parent
e2b4b7f330
commit
933b313267
10
require.php
Normal file
10
require.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
// Require all interfaces
|
||||
require './src/interfaces/Database.php';
|
||||
require './src/interfaces/Insertion.php';
|
||||
require './src/interfaces/Migration.php';
|
||||
require './src/interfaces/Query.php';
|
||||
require './src/interfaces/Table.php';
|
||||
require './src/interfaces/Update.php';
|
||||
|
||||
// Require all classes
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace QueryBuilder;
|
||||
|
||||
interface Query
|
||||
{
|
||||
/**
|
||||
* Finishes the database query.
|
||||
* @return array Query Results
|
||||
*/
|
||||
public function query() : array;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace QueryBuilder;
|
||||
|
||||
interface QueryBuilder
|
||||
{
|
||||
/**
|
||||
* Initializes a Query instance.
|
||||
* @param string ...$tableNames Instance will query on the joined tables.
|
||||
* @return Query Generated instance to build on.
|
||||
*/
|
||||
public static function makeQuery(string ...$tableNames) : Query;
|
||||
|
||||
/**
|
||||
* Initializes an Update instance.
|
||||
* @param string ...$tableNames Instance will update on the joined tables.
|
||||
* @return Update Generated instance to build on.
|
||||
*/
|
||||
public static function makeUpdate(string ...$tableNames) : Update;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace QueryBuilder;
|
||||
|
||||
interface Update
|
||||
{
|
||||
/**
|
||||
* Finishes the database update.
|
||||
* @return array Query Results
|
||||
*/
|
||||
public function query() : array;
|
||||
}
|
59
src/interfaces/Database.php
Normal file
59
src/interfaces/Database.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace DatabaseHelper\interfaces;
|
||||
|
||||
interface Database
|
||||
{
|
||||
/**
|
||||
* Initializes a Table instance to represent a database table.
|
||||
* This instance can be used to define and finalĺy create database tables.
|
||||
*
|
||||
* @param string $tableName The name of the table.
|
||||
* @return Table Generated Table instance.
|
||||
*/
|
||||
public static function makeTable(string $tableName): Table;
|
||||
|
||||
/**
|
||||
* Initializes a Migration instance for managing database migrations for the specified table.
|
||||
*
|
||||
* @param Table $table The table for which the migration is being created.
|
||||
* @return Migration Generated Migration instance.
|
||||
*/
|
||||
public static function makeMigration(Table $table): Migration;
|
||||
|
||||
/**
|
||||
* Initializes a Query instance to perform operations on the specified tables.
|
||||
* When multiple tables are provided, they will be joined automatically for the query.
|
||||
*
|
||||
* @param Table ...$tables One or more Table instances.
|
||||
* @return Query Generated Query instance.
|
||||
*/
|
||||
public static function makeQuery(Table ...$tables): Query;
|
||||
|
||||
/**
|
||||
* Initializes a Query instance specifically for inserting data into the specified tables.
|
||||
* When multiple tables are provided, they will be joined automatically for the insertion.
|
||||
*
|
||||
* @param Table ...$tables One or more Table instances.
|
||||
* @return Query Generated Query instance.
|
||||
*/
|
||||
public static function makeInsertion(Table ...$tables): Query;
|
||||
|
||||
/**
|
||||
* Initializes an Update instance to perform updates on the specified tables.
|
||||
* When multiple tables are provided, they will be joined automatically.
|
||||
*
|
||||
* @param Table ...$tables One or more Table instances.
|
||||
* @return Update Generated Update instance.
|
||||
*/
|
||||
public static function makeUpdate(Table ...$tables): Update;
|
||||
|
||||
/**
|
||||
* Standardizes table names by ensuring they include the WordPress database prefix.
|
||||
* If the prefix is not already present, it will be added.
|
||||
* The provided name(s) are passed by reference and will be modified directly.
|
||||
*
|
||||
* @param string &...$tableName The table names to standardize.
|
||||
*/
|
||||
public static function standardizeTableNames(string &...$tableName): string;
|
||||
|
||||
}
|
8
src/interfaces/Insertion.php
Normal file
8
src/interfaces/Insertion.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace DatabaseHelper\interfaces;
|
||||
|
||||
interface Insertion
|
||||
{
|
||||
public function exec() : array;
|
||||
}
|
8
src/interfaces/Migration.php
Normal file
8
src/interfaces/Migration.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace DatabaseHelper\interfaces;
|
||||
|
||||
interface Migration
|
||||
{
|
||||
public function exec() : array;
|
||||
}
|
8
src/interfaces/Query.php
Normal file
8
src/interfaces/Query.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace DatabaseHelper\interfaces;
|
||||
|
||||
interface Query
|
||||
{
|
||||
public function exec() : array;
|
||||
}
|
8
src/interfaces/Table.php
Normal file
8
src/interfaces/Table.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace DatabaseHelper\interfaces;
|
||||
|
||||
interface Table
|
||||
{
|
||||
public function exec() : void;
|
||||
}
|
8
src/interfaces/Update.php
Normal file
8
src/interfaces/Update.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace DatabaseHelper\interfaces;
|
||||
|
||||
interface Update
|
||||
{
|
||||
public function exec() : array;
|
||||
}
|
Loading…
Reference in New Issue
Block a user