\Cake\Database\DriverPDODriverTrait

PDO driver trait

Summary

Methods
Properties
Constants
connection()
disconnect()
isConnected()
prepare()
beginTransaction()
commitTransaction()
rollbackTransaction()
quote()
lastInsertId()
supportsQuoting()
No public properties found
No constants found
_connect()
$_connection
N/A
No private methods found
No private properties found
N/A

Properties

$_connection

$_connection : \PDO|null

Instance of PDO.

Type

\PDO|null

Methods

connection()

connection(null|\PDO  $connection = null) : \PDO

Returns correct connection resource or object that is internally used If first argument is passed, it will set internal connection object or result to the value passed

Parameters

null|\PDO $connection

The PDO connection instance.

Returns

\PDO —

connection object used internally

disconnect()

disconnect() : void

Disconnects from database server

isConnected()

isConnected() : boolean

Checks whether or not the driver is connected.

Returns

boolean

beginTransaction()

beginTransaction() : boolean

Starts a transaction

Returns

boolean —

true on success, false otherwise

commitTransaction()

commitTransaction() : boolean

Commits a transaction

Returns

boolean —

true on success, false otherwise

rollbackTransaction()

rollbackTransaction() : boolean

Rollback a transaction

Returns

boolean —

true on success, false otherwise

quote()

quote(mixed  $value, string  $type) : string

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

Parameters

mixed $value

The value to quote.

string $type

Type to be used for determining kind of quoting to perform

Returns

string

lastInsertId()

lastInsertId(string|null  $table = null, string|null  $column = null) : string|integer

Returns last id generated for a table or sequence in database

Parameters

string|null $table

table name or sequence to get last insert value from

string|null $column

the name of the column representing the primary key

Returns

string|integer

supportsQuoting()

supportsQuoting() : boolean

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

Returns

boolean

_connect()

_connect(string  $dsn, array  $config) : boolean

Establishes a connection to the database server

Parameters

string $dsn

A Driver-specific PDO-DSN

array $config

configuration to be used for creating connection

Returns

boolean —

true on success