2016-10-06 02:08:43 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2016-10-06 02:08:43 +00:00
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse\Db;
|
2016-10-06 02:08:43 +00:00
|
|
|
|
2017-03-02 14:04:04 +00:00
|
|
|
interface Driver {
|
2017-05-07 22:27:16 +00:00
|
|
|
const TR_PEND = 0;
|
|
|
|
const TR_COMMIT = 1;
|
|
|
|
const TR_ROLLBACK = 2;
|
|
|
|
const TR_PEND_COMMIT = -1;
|
|
|
|
const TR_PEND_ROLLBACK = -2;
|
2018-10-26 18:58:04 +00:00
|
|
|
|
2017-12-18 23:29:32 +00:00
|
|
|
public static function create(): Driver;
|
2017-02-16 20:29:42 +00:00
|
|
|
// returns a human-friendly name for the driver (for display in installer, for example)
|
2017-08-29 14:50:31 +00:00
|
|
|
public static function driverName(): string;
|
2017-02-16 20:29:42 +00:00
|
|
|
// returns the version of the scheme of the opened database; if uninitialized should return 0
|
2017-08-29 14:50:31 +00:00
|
|
|
public function schemaVersion(): int;
|
2017-12-18 23:29:32 +00:00
|
|
|
// returns the schema set to be used for database set-up
|
|
|
|
public static function schemaID(): string;
|
2017-05-06 16:02:27 +00:00
|
|
|
// return a Transaction object
|
2017-08-29 14:50:31 +00:00
|
|
|
public function begin(bool $lock = false): Transaction;
|
2017-05-06 16:02:27 +00:00
|
|
|
// manually begin a real or synthetic transactions, with real or synthetic nesting
|
2017-08-29 14:50:31 +00:00
|
|
|
public function savepointCreate(): int;
|
2017-05-06 16:02:27 +00:00
|
|
|
// manually commit either the latest or all pending nested transactions
|
2017-08-29 14:50:31 +00:00
|
|
|
public function savepointRelease(int $index = null): bool;
|
2017-05-06 16:02:27 +00:00
|
|
|
// manually rollback either the latest or all pending nested transactions
|
2017-08-29 14:50:31 +00:00
|
|
|
public function savepointUndo(int $index = null): bool;
|
2017-02-16 20:29:42 +00:00
|
|
|
// attempt to perform an in-place upgrade of the database schema; this may be a no-op which always throws an exception
|
2017-08-29 14:50:31 +00:00
|
|
|
public function schemaUpdate(int $to): bool;
|
2017-02-16 20:29:42 +00:00
|
|
|
// execute one or more unsanitized SQL queries and return an indication of success
|
2017-08-29 14:50:31 +00:00
|
|
|
public function exec(string $query): bool;
|
2017-02-16 20:29:42 +00:00
|
|
|
// perform a single unsanitized query and return a result set
|
2017-08-29 14:50:31 +00:00
|
|
|
public function query(string $query): Result;
|
2017-02-16 20:29:42 +00:00
|
|
|
// ready a prepared statement for later execution
|
2017-08-29 14:50:31 +00:00
|
|
|
public function prepare(string $query, ...$paramType): Statement;
|
|
|
|
public function prepareArray(string $query, array $paramTypes): Statement;
|
2017-11-29 23:14:59 +00:00
|
|
|
// report whether the database character set is correct/acceptable
|
|
|
|
public function charsetAcceptable(): bool;
|
2018-12-05 01:41:21 +00:00
|
|
|
// return an implementation-dependent form of a reference SQL function or operator
|
|
|
|
public function sqlToken(string $token): string;
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|