Trait PDODriverTrait
PDO driver trait
Property Summary
- 
        $_connection protectedPDOInstance of PDO. 
Method Summary
- 
          _connect() protectedEstablishes a connection to the database server 
- 
          beginTransaction() publicStarts a transaction 
- 
          commitTransaction() publicCommits a transaction 
- 
          connection() publicReturns 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 
- 
          disconnect() publicDisconnects from database server 
- 
          lastInsertId() publicReturns last id generated for a table or sequence in database 
- 
          prepare() publicPrepares a sql statement to be executed 
- 
          quote() publicReturns a value in a safe representation to be used in a query string 
- 
          rollbackTransaction() publicRollsback a transaction 
- 
          supportsQuoting() publicChecks if the driver supports quoting, as PDO_ODBC does not support it. 
Method Detail
_connect() ¶ protected
_connect(string $dsn, array $config): boolEstablishes a connection to the database server
Parameters
- 
                string$dsn
- A Driver-specific PDO-DSN 
- 
                array$config
- configuration to be used for creating connection 
Returns
booltrue on success
beginTransaction() ¶ public
beginTransaction(): boolStarts a transaction
Returns
booltrue on success, false otherwise
commitTransaction() ¶ public
commitTransaction(): boolCommits a transaction
Returns
booltrue on success, false otherwise
connection() ¶ public
connection(null|PDO $connection = null): mixedReturns 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 optional
- The PDO connection instance. 
Returns
mixedconnection object used internally
lastInsertId() ¶ public
lastInsertId(string|null $table = null, string|null $column = null): string|intReturns last id generated for a table or sequence in database
Parameters
- 
                string|null$table optional
- table name or sequence to get last insert value from 
- 
                string|null$column optional
- the name of the column representing the primary key 
Returns
string|intprepare() ¶ public
prepare(string|Cake\Database\Query $query): Cake\Database\StatementInterfacePrepares a sql statement to be executed
Parameters
- 
                string|Cake\Database\Query$query
- The query to turn into a prepared statement. 
Returns
Cake\Database\StatementInterfacequote() ¶ public
quote(mixed $value, string $type): stringReturns 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
stringrollbackTransaction() ¶ public
rollbackTransaction(): boolRollsback a transaction
Returns
booltrue on success, false otherwise
supportsQuoting() ¶ public
supportsQuoting(): boolChecks if the driver supports quoting, as PDO_ODBC does not support it.
Returns
bool