-
-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathDatabase.php
More file actions
56 lines (45 loc) · 1.28 KB
/
Database.php
File metadata and controls
56 lines (45 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace Tempest\Database;
use Tempest\Database\Builder\QueryBuilders\BuildsQuery;
use Tempest\Database\Config\DatabaseDialect;
use Tempest\Support\Str\ImmutableString;
use UnitEnum;
/**
* Represents a database that can execute queries.
*/
interface Database
{
/**
* The dialect of this database.
*/
public DatabaseDialect $dialect { get; }
/**
* The tag associated with this database, if any.
*/
public null|string|UnitEnum $tag { get; }
/**
* Executes the given query.
*/
public function execute(BuildsQuery|Query $query): void;
/**
* Returns the last inserted primary key, if any.
*/
public function getLastInsertId(): ?PrimaryKey;
/**
* Fetches all results for the given query.
*/
public function fetch(BuildsQuery|Query $query): array;
/**
* Fetches the first result for the given query.
*/
public function fetchFirst(BuildsQuery|Query $query): ?array;
/**
* Executes the given callback within a transaction.
*/
public function withinTransaction(callable $callback): bool;
/**
* Returns the raw SQL representation of the given query for debugging purposes.
*/
public function getRawSql(Query $query): ImmutableString;
}