|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of the Dibi, smart database abstraction layer (https://dibiphp.com) |
| 5 | + * Copyright (c) 2005 David Grudl (https://davidgrudl.com) |
| 6 | + */ |
| 7 | + |
| 8 | +declare(strict_types=1); |
| 9 | + |
| 10 | +namespace Dibi\Drivers; |
| 11 | + |
| 12 | +use Dibi\DriverException; |
| 13 | +use Dibi\Exception; |
| 14 | + |
| 15 | + |
| 16 | +/** |
| 17 | + * Database connection driver. |
| 18 | + */ |
| 19 | +interface Connection |
| 20 | +{ |
| 21 | + /** |
| 22 | + * Disconnects from a database. |
| 23 | + * @throws Exception |
| 24 | + */ |
| 25 | + function disconnect(): void; |
| 26 | + |
| 27 | + /** |
| 28 | + * Internal: Executes the SQL query. |
| 29 | + * @throws DriverException |
| 30 | + */ |
| 31 | + function query(string $sql): ?Result; |
| 32 | + |
| 33 | + /** |
| 34 | + * Gets the number of affected rows by the last INSERT, UPDATE or DELETE query. |
| 35 | + */ |
| 36 | + function getAffectedRows(): ?int; |
| 37 | + |
| 38 | + /** |
| 39 | + * Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query. |
| 40 | + */ |
| 41 | + function getInsertId(?string $sequence): ?int; |
| 42 | + |
| 43 | + /** |
| 44 | + * Begins a transaction (if supported). |
| 45 | + * @throws DriverException |
| 46 | + */ |
| 47 | + function begin(?string $savepoint = null): void; |
| 48 | + |
| 49 | + /** |
| 50 | + * Commits statements in a transaction. |
| 51 | + * @throws DriverException |
| 52 | + */ |
| 53 | + function commit(?string $savepoint = null): void; |
| 54 | + |
| 55 | + /** |
| 56 | + * Rollback changes in a transaction. |
| 57 | + * @throws DriverException |
| 58 | + */ |
| 59 | + function rollback(?string $savepoint = null): void; |
| 60 | + |
| 61 | + /** |
| 62 | + * Returns the connection resource. |
| 63 | + */ |
| 64 | + function getResource(): mixed; |
| 65 | + |
| 66 | + /** |
| 67 | + * Returns the connection reflector. |
| 68 | + */ |
| 69 | + function getReflector(): Engine; |
| 70 | + |
| 71 | + /** |
| 72 | + * Encodes data for use in a SQL statement. |
| 73 | + */ |
| 74 | + function escapeText(string $value): string; |
| 75 | + |
| 76 | + function escapeBinary(string $value): string; |
| 77 | + |
| 78 | + function escapeIdentifier(string $value): string; |
| 79 | + |
| 80 | + function escapeBool(bool $value): string; |
| 81 | + |
| 82 | + function escapeDate(\DateTimeInterface $value): string; |
| 83 | + |
| 84 | + function escapeDateTime(\DateTimeInterface $value): string; |
| 85 | + |
| 86 | + function escapeDateInterval(\DateInterval $value): string; |
| 87 | + |
| 88 | + /** |
| 89 | + * Encodes string for use in a LIKE statement. |
| 90 | + */ |
| 91 | + function escapeLike(string $value, int $pos): string; |
| 92 | + |
| 93 | + /** |
| 94 | + * Injects LIMIT/OFFSET to the SQL query. |
| 95 | + */ |
| 96 | + function applyLimit(string &$sql, ?int $limit, ?int $offset): void; |
| 97 | +} |
0 commit comments