DriverInterface
in
Interface for database driver.
Table of Contents
Constants
- FEATURE_CTE = 'cte'
- Common Table Expressions (with clause) support.
- FEATURE_DISABLE_CONSTRAINT_WITHOUT_TRANSACTION = 'disable-constraint-without-transaction'
- Disabling constraints without being in transaction support.
- FEATURE_JSON = 'json'
- Native JSON data type support.
- FEATURE_QUOTE = 'quote'
- PDO::quote() support.
- FEATURE_SAVEPOINT = 'savepoint'
- Transaction savepoint support.
- FEATURE_TRUNCATE_WITH_CONSTRAINTS = 'truncate-with-constraints'
- Truncate with foreign keys attached support.
- FEATURE_WINDOW = 'window'
- Window function support (all or partial clauses).
Methods
- beginTransaction() : bool
- Starts a transaction.
- commitTransaction() : bool
- Commits a transaction.
- compileQuery() : array<string|int, mixed>
- Transforms the passed query to this Driver's dialect and returns an instance of the transformed query and the full compiled SQL string.
- connect() : bool
- Establishes a connection to the database server.
- disableAutoQuoting() : $this
- Disable auto quoting of identifiers in queries.
- disableForeignKeySQL() : string
- Get the SQL for disabling foreign keys.
- disconnect() : void
- Disconnects from database server.
- enableAutoQuoting() : $this
- Sets whether this driver should automatically quote identifiers in queries.
- enabled() : bool
- Returns whether php is able to use this driver for connecting to database.
- enableForeignKeySQL() : string
- Get the SQL for enabling foreign keys.
- getConnection() : object
- Returns correct connection resource or object that is internally used.
- isAutoQuotingEnabled() : bool
- Returns whether this driver should automatically quote identifiers in queries.
- isConnected() : bool
- Checks whether the driver is connected.
- lastInsertId() : string|int
- Returns last id generated for a table or sequence in database.
- newCompiler() : QueryCompiler
- Returns an instance of a QueryCompiler.
- newTableSchema() : TableSchema
- Constructs new TableSchema.
- prepare() : StatementInterface
- Prepares a sql statement to be executed.
- queryTranslator() : Closure
- Returns a callable function that will be used to transform a passed Query object.
- quote() : string
- Returns a value in a safe representation to be used in a query string
- quoteIdentifier() : string
- Quotes a database identifier (a column name, table name, etc..) to be used safely in queries without the risk of using reserved words.
- releaseSavePointSQL() : string
- Get the SQL for releasing a save point.
- rollbackSavePointSQL() : string
- Get the SQL for rollingback a save point.
- rollbackTransaction() : bool
- Rollbacks a transaction.
- savePointSQL() : string
- Get the SQL for creating a save point.
- schema() : string
- Returns the schema name that's being used.
- schemaDialect() : SchemaDialect
- Get the schema dialect.
- schemaValue() : string
- Escapes values for use in schema definitions.
- setConnection() : $this
- Set the internal connection object.
- supportsDynamicConstraints() : bool
- Returns whether the driver supports adding or dropping constraints to already created tables.
- supportsQuoting() : bool
- Checks if the driver supports quoting.
- supportsSavePoints() : bool
- Returns whether this driver supports save points for nested transactions.
Constants
FEATURE_CTE
Common Table Expressions (with clause) support.
public
string
FEATURE_CTE
= 'cte'
FEATURE_DISABLE_CONSTRAINT_WITHOUT_TRANSACTION
Disabling constraints without being in transaction support.
public
string
FEATURE_DISABLE_CONSTRAINT_WITHOUT_TRANSACTION
= 'disable-constraint-without-transaction'
FEATURE_JSON
Native JSON data type support.
public
string
FEATURE_JSON
= 'json'
FEATURE_QUOTE
PDO::quote() support.
public
string
FEATURE_QUOTE
= 'quote'
FEATURE_SAVEPOINT
Transaction savepoint support.
public
string
FEATURE_SAVEPOINT
= 'savepoint'
FEATURE_TRUNCATE_WITH_CONSTRAINTS
Truncate with foreign keys attached support.
public
string
FEATURE_TRUNCATE_WITH_CONSTRAINTS
= 'truncate-with-constraints'
FEATURE_WINDOW
Window function support (all or partial clauses).
public
string
FEATURE_WINDOW
= 'window'
Methods
beginTransaction()
Starts a transaction.
public
beginTransaction() : bool
Return values
bool —True on success, false otherwise.
commitTransaction()
Commits a transaction.
public
commitTransaction() : bool
Return values
bool —True on success, false otherwise.
compileQuery()
Transforms the passed query to this Driver's dialect and returns an instance of the transformed query and the full compiled SQL string.
public
compileQuery(Query $query, ValueBinder $binder) : array<string|int, mixed>
Parameters
- $query : Query
-
The query to compile.
- $binder : ValueBinder
-
The value binder to use.
Return values
array<string|int, mixed> —containing 2 entries. The first entity is the transformed query and the second one the compiled SQL.
connect()
Establishes a connection to the database server.
public
connect() : bool
Tags
Return values
bool —True on success, false on failure.
disableAutoQuoting()
Disable auto quoting of identifiers in queries.
public
disableAutoQuoting() : $this
Return values
$thisdisableForeignKeySQL()
Get the SQL for disabling foreign keys.
public
disableForeignKeySQL() : string
Return values
stringdisconnect()
Disconnects from database server.
public
disconnect() : void
enableAutoQuoting()
Sets whether this driver should automatically quote identifiers in queries.
public
enableAutoQuoting([bool $enable = true ]) : $this
Parameters
- $enable : bool = true
-
Whether to enable auto quoting
Return values
$thisenabled()
Returns whether php is able to use this driver for connecting to database.
public
enabled() : bool
Return values
bool —True if it is valid to use this driver.
enableForeignKeySQL()
Get the SQL for enabling foreign keys.
public
enableForeignKeySQL() : string
Return values
stringgetConnection()
Returns correct connection resource or object that is internally used.
public
getConnection() : object
Return values
object —Connection object used internally.
isAutoQuotingEnabled()
Returns whether this driver should automatically quote identifiers in queries.
public
isAutoQuotingEnabled() : bool
Return values
boolisConnected()
Checks whether the driver is connected.
public
isConnected() : bool
Return values
boollastInsertId()
Returns last id generated for a table or sequence in database.
public
lastInsertId([string|null $table = null ][, string|null $column = null ]) : string|int
Parameters
- $table : string|null = null
-
table name or sequence to get last insert value from.
- $column : string|null = null
-
the name of the column representing the primary key.
Return values
string|intnewCompiler()
Returns an instance of a QueryCompiler.
public
newCompiler() : QueryCompiler
Return values
QueryCompilernewTableSchema()
Constructs new TableSchema.
public
newTableSchema(string $table[, array<string|int, mixed> $columns = [] ]) : TableSchema
Parameters
- $table : string
-
The table name.
- $columns : array<string|int, mixed> = []
-
The list of columns for the schema.
Return values
TableSchemaprepare()
Prepares a sql statement to be executed.
public
prepare(Query|string $query) : StatementInterface
Parameters
- $query : Query|string
-
The query to turn into a prepared statement.
Return values
StatementInterfacequeryTranslator()
Returns a callable function that will be used to transform a passed Query object.
public
queryTranslator(string $type) : Closure
This function, in turn, will return an instance of a Query object that has been transformed to accommodate any specificities of the SQL dialect in use.
Parameters
- $type : string
-
The type of query to be transformed (select, insert, update, delete).
Return values
Closurequote()
Returns a value in a safe representation to be used in a query string
public
quote(mixed $value, int $type) : string
Parameters
- $value : mixed
-
The value to quote.
- $type : int
-
Must be one of the \PDO::PARAM_* constants
Return values
stringquoteIdentifier()
Quotes a database identifier (a column name, table name, etc..) to be used safely in queries without the risk of using reserved words.
public
quoteIdentifier(string $identifier) : string
Parameters
- $identifier : string
-
The identifier expression to quote.
Return values
stringreleaseSavePointSQL()
Get the SQL for releasing a save point.
public
releaseSavePointSQL(string|int $name) : string
Parameters
- $name : string|int
-
Save point name or id
Return values
stringrollbackSavePointSQL()
Get the SQL for rollingback a save point.
public
rollbackSavePointSQL(string|int $name) : string
Parameters
- $name : string|int
-
Save point name or id
Return values
stringrollbackTransaction()
Rollbacks a transaction.
public
rollbackTransaction() : bool
Return values
bool —True on success, false otherwise.
savePointSQL()
Get the SQL for creating a save point.
public
savePointSQL(string|int $name) : string
Parameters
- $name : string|int
-
Save point name or id
Return values
stringschema()
Returns the schema name that's being used.
public
schema() : string
Return values
stringschemaDialect()
Get the schema dialect.
public
schemaDialect() : SchemaDialect
Used by package to reflect schema and generate schema.
If all the tables that use this Driver specify their own schemas, then this may return null.
Return values
SchemaDialectschemaValue()
Escapes values for use in schema definitions.
public
schemaValue(mixed $value) : string
Parameters
- $value : mixed
-
The value to escape.
Return values
string —String for use in schema definitions.
setConnection()
Set the internal connection object.
public
setConnection(object $connection) : $this
Parameters
- $connection : object
-
The connection instance.
Return values
$thissupportsDynamicConstraints()
Returns whether the driver supports adding or dropping constraints to already created tables.
public
supportsDynamicConstraints() : bool
Fixtures no longer dynamically drop and create constraints.
Return values
bool —True if driver supports dynamic constraints.
supportsQuoting()
Checks if the driver supports quoting.
public
supportsQuoting() : bool
Use supports(DriverInterface::FEATURE_QUOTE)
instead
Return values
boolsupportsSavePoints()
Returns whether this driver supports save points for nested transactions.
public
supportsSavePoints() : bool
Use supports(DriverInterface::FEATURE_SAVEPOINT)
instead
Return values
bool —True if save points are supported, false otherwise.