ringfinger/backend/classes/core/DatabaseInterface.php

80 lines
1.7 KiB
PHP
Raw Normal View History

2020-08-17 23:46:58 +02:00
<?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;
/**
2020-08-19 21:06:45 +02:00
* Selects backend from a table.
2020-08-17 23:46:58 +02:00
*/
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;
/**
2020-08-19 21:06:45 +02:00
* Edits backend inside a table.
2020-08-17 23:46:58 +02:00
*/
public function Update(string $table, array $fields, array $conditions): void;
/**
* Returns the number of entries found.
*/
public function Count(string $table, array $conditions = []): int;
2020-08-18 11:46:03 +02:00
/*
* Returns if there's an open transaction.
*/
public function hasTransaction(): bool;
/*
* Starts a transaction that can later be committed or rolled back.
*/
public function startTransaction(): void;
/*
* Quits a current transaction without saving.
*/
public function rollback(): void;
/*
* Saves and exits a current transaction.
*/
public function commit(): void;
2020-08-17 23:46:58 +02:00
/**
* Returns the primary key from the last inserted row.
*/
public function GetLastInsertedId(): int;
}