ringfinger/data/classes/core/DatabaseInterface.php
2020-08-17 23:46:58 +02:00

60 lines
1.3 KiB
PHP

<?php
interface DatabaseInterface
{
public const ORDER_ASC = true;
public const ORDER_DESC = false;
/**
* Has to close the connection.
*/
public function __destruct();
/**
* Sends an sql query to the database.
*/
public function Query(string $query, array $params = []): void;
/**
* @return array
*/
public function getResult(): array;
/**
* Selects data from a table.
*/
public function Select(
string $tableName,
array $fields = [],
array $conditions = [],
int $limit = 0,
array $orderBy = [],
bool $asc = true,
int $offset = 0
): array;
/**
* Deletes rows from a table.
*/
public function Delete(string $table, array $conditions): void;
/**
* Inserts a new row into the table.
*/
public function Insert(string $table, array $fields): ?int;
/**
* Edits data inside a table.
*/
public function Update(string $table, array $fields, array $conditions): void;
/**
* Returns the number of entries found.
*/
public function Count(string $table, array $conditions = []): int;
/**
* Returns the primary key from the last inserted row.
*/
public function GetLastInsertedId(): int;
}