Fr3nch13/CakePHP Utilities

Driver
in package
implements DriverInterface

AbstractYes

Represents a database driver containing all specificities for a database engine including its SQL dialect.

Table of Contents

Interfaces

DriverInterface
Interface for database driver.

Constants

MAX_ALIAS_LENGTH  = null
RETRY_ERROR_CODES  = []

Properties

$_autoQuoting  : bool
Indicates whether the driver is doing automatic identifier quoting for all queries
$_baseConfig  : array<string, mixed>
Base configuration that is merged into the user supplied configuration data.
$_config  : array<string, mixed>
Configuration data.
$_connection  : PDO
Instance of PDO.
$_version  : string|null
The server version
$connectRetries  : int
The last number of connection retry attempts.

Methods

__construct()  : mixed
Constructor
__debugInfo()  : array<string, mixed>
Returns an array that can be used to describe the internal state of this object.
__destruct()  : mixed
Destructor
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.
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.
getConnection()  : PDO
Get the internal PDO connection instance.
getConnectRetries()  : int
Returns the number of connection retry attempts made.
getMaxAliasLength()  : int|null
Returns the maximum alias length allowed.
inTransaction()  : bool
Returns whether a transaction is active for connection.
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.
rollbackTransaction()  : bool
Rollbacks a transaction.
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 PDO connection instance.
supports()  : bool
Returns whether the driver supports the feature.
supportsCTEs()  : bool
Returns true if the server supports common table expressions.
supportsQuoting()  : bool
Checks if the driver supports quoting, as PDO_ODBC does not support it.
supportsSavePoints()  : bool
Returns whether this driver supports save points for nested transactions.
version()  : string
Returns connected server version.
_connect()  : bool
Establishes a connection to the database server

Constants

MAX_ALIAS_LENGTH

protected int|null MAX_ALIAS_LENGTH = null

Maximum alias length or null if no limit

RETRY_ERROR_CODES

protected array<string|int, int> RETRY_ERROR_CODES = []

DB-specific error codes that allow connect retry

Properties

$_autoQuoting

Indicates whether the driver is doing automatic identifier quoting for all queries

protected bool $_autoQuoting = false

$_baseConfig

Base configuration that is merged into the user supplied configuration data.

protected array<string, mixed> $_baseConfig = []

$_config

Configuration data.

protected array<string, mixed> $_config

$_connection

Instance of PDO.

protected PDO $_connection

$_version

The server version

protected string|null $_version

$connectRetries

The last number of connection retry attempts.

protected int $connectRetries = 0

Methods

__construct()

Constructor

public __construct([array<string, mixed> $config = [] ]) : mixed
Parameters
$config : array<string, mixed> = []

The configuration for the driver.

Tags
throws
InvalidArgumentException

__debugInfo()

Returns an array that can be used to describe the internal state of this object.

public __debugInfo() : array<string, mixed>
Return values
array<string, mixed>

__destruct()

Destructor

public __destruct() : mixed

beginTransaction()

Starts a transaction.

public beginTransaction() : bool
Tags
inheritDoc
Return values
bool —

True on success, false otherwise.

commitTransaction()

Commits a transaction.

public commitTransaction() : bool
Tags
inheritDoc
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.

Tags
inheritDoc
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 abstract connect() : bool
Tags
inheritDoc
Return values
bool —

True on success, false on failure.

disableAutoQuoting()

Disable auto quoting of identifiers in queries.

public disableAutoQuoting() : $this
Tags
inheritDoc
Return values
$this

disconnect()

Disconnects from database server.

public disconnect() : void
Tags
inheritDoc

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

Tags
inheritDoc
Return values
$this

enabled()

Returns whether php is able to use this driver for connecting to database.

public abstract enabled() : bool
Tags
inheritDoc
Return values
bool —

True if it is valid to use this driver.

getConnection()

Get the internal PDO connection instance.

public getConnection() : PDO
Return values
PDO

getConnectRetries()

Returns the number of connection retry attempts made.

public getConnectRetries() : int
Return values
int

getMaxAliasLength()

Returns the maximum alias length allowed.

public getMaxAliasLength() : int|null

This can be different from the maximum identifier length for columns.

Return values
int|null —

Maximum alias length or null if no limit

inTransaction()

Returns whether a transaction is active for connection.

public inTransaction() : bool
Return values
bool

isAutoQuotingEnabled()

Returns whether this driver should automatically quote identifiers in queries.

public isAutoQuotingEnabled() : bool
Tags
inheritDoc
Return values
bool

isConnected()

Checks whether the driver is connected.

public isConnected() : bool
Tags
inheritDoc
Return values
bool

lastInsertId()

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.

Tags
inheritDoc
Return values
string|int

newCompiler()

Returns an instance of a QueryCompiler.

public newCompiler() : QueryCompiler
Tags
inheritDoc
Return values
QueryCompiler

newTableSchema()

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.

Tags
inheritDoc
Return values
TableSchema

prepare()

Prepares a sql statement to be executed.

public prepare(mixed $query) : StatementInterface
Parameters
$query : mixed

The query to turn into a prepared statement.

Tags
inheritDoc
Return values
StatementInterface

queryTranslator()

Returns a callable function that will be used to transform a passed Query object.

public abstract queryTranslator(string $type) : Closure
Parameters
$type : string

The type of query to be transformed (select, insert, update, delete).

Tags
inheritDoc
Return values
Closure

quote()

Returns a value in a safe representation to be used in a query string

public quote(mixed $value[, mixed $type = PDO::PARAM_STR ]) : string
Parameters
$value : mixed

The value to quote.

$type : mixed = PDO::PARAM_STR

Must be one of the \PDO::PARAM_* constants

Tags
inheritDoc
Return values
string

quoteIdentifier()

Quotes a database identifier (a column name, table name, etc..) to be used safely in queries without the risk of using reserved words.

public abstract quoteIdentifier(string $identifier) : string
Parameters
$identifier : string

The identifier expression to quote.

Tags
inheritDoc
Return values
string

rollbackTransaction()

Rollbacks a transaction.

public rollbackTransaction() : bool
Tags
inheritDoc
Return values
bool —

True on success, false otherwise.

schema()

Returns the schema name that's being used.

public schema() : string
Tags
inheritDoc
Return values
string

schemaValue()

Escapes values for use in schema definitions.

public schemaValue(mixed $value) : string
Parameters
$value : mixed

The value to escape.

Tags
inheritDoc
Return values
string —

String for use in schema definitions.

setConnection()

Set the internal PDO connection instance.

public setConnection(PDO $connection) : $this
Parameters
$connection : PDO

PDO instance.

Tags
psalm-suppress

MoreSpecificImplementedParamType

Return values
$this

supports()

Returns whether the driver supports the feature.

public supports(string $feature) : bool

Defaults to true for FEATURE_QUOTE and FEATURE_SAVEPOINT.

Parameters
$feature : string

Driver feature name

Return values
bool

supportsCTEs()

Returns true if the server supports common table expressions.

public supportsCTEs() : bool

Use supports(DriverInterface::FEATURE_QUOTE) instead

Return values
bool

supportsQuoting()

Checks if the driver supports quoting, as PDO_ODBC does not support it.

public supportsQuoting() : bool

Use supports(DriverInterface::FEATURE_QUOTE) instead

Return values
bool

supportsSavePoints()

Returns whether this driver supports save points for nested transactions.

public supportsSavePoints() : bool
Tags
inheritDoc
Return values
bool —

True if save points are supported, false otherwise.

version()

Returns connected server version.

public version() : string
Return values
string

_connect()

Establishes a connection to the database server

protected _connect(string $dsn, array<string, mixed> $config) : bool
Parameters
$dsn : string

A Driver-specific PDO-DSN

$config : array<string, mixed>

configuration to be used for creating connection

Return values
bool —

true on success


        
On this page

Search results