2016-10-06 02:08:43 +00:00
< ? php
declare ( strict_types = 1 );
namespace JKingWeb\NewsSync\Db ;
2016-10-17 20:49:39 +00:00
interface Driver {
// returns an instance of a class implementing this interface. Implemented as a static method so that classes may return their PDO equivalents instead of themselves
static function create ( \JKingWeb\NewsSync\RuntimeData $data , bool $install = false ) : Driver ;
// returns a human-friendly name for the driver (for display in installer, for example)
2016-10-06 02:08:43 +00:00
static function driverName () : string ;
2016-10-17 20:49:39 +00:00
// returns the version of the scheme of the opened database; if uninitialized should return 0
2016-10-06 02:08:43 +00:00
function schemaVersion () : int ;
2016-10-17 20:49:39 +00:00
// begin a real or synthetic transactions, with real or synthetic nesting
2016-10-06 02:08:43 +00:00
function begin () : bool ;
2016-10-17 20:49:39 +00:00
// 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 update ( int $to ) : bool ;
// execute one or more unsanitized SQL queries and return an indication of success
2016-10-06 02:08:43 +00:00
function exec ( string $query ) : bool ;
2016-10-17 20:49:39 +00:00
// perform a single unsanitized query and return a result set
function query ( string $query ) : Result ;
// ready a prepared statement for later execution
2016-10-06 02:08:43 +00:00
function prepare ( string $query , string ... $paramType ) : Statement ;
}