2025-01-24 13:26:48 +01:00
|
|
|
<?php
|
|
|
|
namespace DatabaseHelper\interfaces;
|
|
|
|
|
2025-01-27 19:35:17 +01:00
|
|
|
interface QueryBuilder
|
2025-01-24 13:26:48 +01:00
|
|
|
{
|
2025-02-03 17:44:52 +01:00
|
|
|
/**
|
|
|
|
* Initializes a query builder with a table blueprint.
|
|
|
|
* @param TableBlueprint $table Table to build queries for.
|
|
|
|
*/
|
|
|
|
public function __construct(TableBlueprint $table);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies the columns to select in the query.
|
|
|
|
* @param string ...$cols The columns to select.
|
|
|
|
* @return QueryBuilder Current instance for method chaining.
|
|
|
|
*/
|
|
|
|
public function select(string ...$cols): QueryBuilder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a WHERE condition to the query.
|
|
|
|
* @param string $col Column name to apply the condition to.
|
|
|
|
* @param string $operator Operator to use in the condition (e.g., '=', '>', '<').
|
|
|
|
* @param mixed $val Value to compare against.
|
|
|
|
* @return QueryBuilder Current instance for method chaining.
|
|
|
|
*/
|
|
|
|
public function where(string $col, string $operator, mixed $val): QueryBuilder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds an AND WHERE condition to the query.
|
|
|
|
* @param string $col Column name to apply the condition to.
|
|
|
|
* @param string $operator Operator to use in the condition (e.g., '=', '>', '<').
|
|
|
|
* @param mixed $val Value to compare against.
|
|
|
|
* @return QueryBuilder Current instance for method chaining.
|
|
|
|
*/
|
|
|
|
public function andWhere(string $col, string $operator, mixed $val): QueryBuilder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds an OR WHERE condition to the query.
|
|
|
|
* @param string $col Column name to apply the condition to.
|
|
|
|
* @param string $operator Operator to use in the condition (e.g., '=', '>', '<').
|
|
|
|
* @param mixed $val Value to compare against.
|
|
|
|
* @return QueryBuilder Current instance for method chaining.
|
|
|
|
*/
|
|
|
|
public function orWhere(string $col, string $operator, mixed $val): QueryBuilder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes the query and returns the result as an associative array.
|
|
|
|
* @return array Result of the query execution.
|
|
|
|
*/
|
|
|
|
public function query(): array;
|
|
|
|
}
|
|
|
|
|