1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 17:12:41 +00:00
Arsse/lib/Db/Driver.php
J. King 929d763981 Simplify the creation of arbitrary UPDATEs
The type parameters of Db\Driver::prepare() and the parameters of Db\Statement::run() can now be arrays, which will be iterated over recursively to bind scalar values to the SQL statement.

This simplifies the construction of arbitrary UPDATE statements (the WHERE clause no longer needs to be taken into account) and should make it clearer what is happening in these cases.

It should also simplify the creation of IN() clauses down the road if they become necessary.
2017-04-06 11:02:47 -04:00

29 lines
No EOL
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace JKingWeb\Arsse\Db;
interface Driver {
function __construct(bool $install = false);
// returns a human-friendly name for the driver (for display in installer, for example)
static function driverName(): string;
// returns the version of the scheme of the opened database; if uninitialized should return 0
function schemaVersion(): int;
// begin a real or synthetic transactions, with real or synthetic nesting
function begin(): bool;
// commit either the latest or all pending nested transactions; use of this method should assume a partial commit is a no-op
function commit(bool $all = false): bool;
// rollback either the latest or all pending nested transactions; use of this method should assume a partial rollback will not work
function rollback(bool $all = false): bool;
// attempt to advise other processes that they should not attempt to access the database; used during live upgrades
function lock(): bool;
function unlock(): bool;
function isLocked(): bool;
// attempt to perform an in-place upgrade of the database schema; this may be a no-op which always throws an exception
function schemaUpdate(int $to): bool;
// execute one or more unsanitized SQL queries and return an indication of success
function exec(string $query): bool;
// perform a single unsanitized query and return a result set
function query(string $query): Result;
// ready a prepared statement for later execution
function prepare(string $query, ...$paramType): Statement;
}