PDOConnector
class PDOConnector extends DBConnector implements TransactionManager
PDO driver database connector
Traits
Config options
emulate_prepare | boolean | Should ATTR_EMULATE_PREPARES flag be used to emulate prepared statements? | |
legacy_types | boolean | Should we return everything as a string in order to allow transaction savepoints? This preserves the behaviour of <= 4.3, including some bugs. | |
ssl_cipher_default | string | Default strong SSL cipher to be used |
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
Gets the uninherited value for the given config option
Determine if this SQL statement is a destructive operation (write or ddl)
Determine if this SQL statement is a write operation (alters content but not structure)
Link this connector to the database given the specified parameters Will throw an exception rather than return a success state.
Query for the version of the currently connected database
Given a value escape this for use in a query for the current database connector. Note that this does not quote the value.
Given a value escape and quote this appropriately for the current database connector.
Executes the following query with the specified error level.
Execute the given SQL parameterised query with the specified arguments
Select a database by name
Retrieves the name of the currently selected database
De-selects the currently selected database
Retrieves the last error generated from the database connection
Determines the last ID generated from the specified table.
Determines the number of affected rows from the last SQL query
Determines if we are connected to a server AND have a valid database selected.
Flush all prepared statements
Retrieve a prepared statement for a given SQL string, or return an already prepared version if one exists for the given query
Is PDO running in emulated mode
Return the driver for this connector E.g. 'mysql', 'sqlsrv', 'pgsql'
Executes a query that doesn't return a resultset
Determines the PDO::PARAM_* type for a given PHP type string
Start a prepared transaction
Complete a transaction
Roll-back a transaction
Return the depth of the transaction For unnested transactions returns 1 while in a transaction, 0 otherwise
Create a new savepoint
Return true if savepoints are supported by this transaction manager.
Details
in Configurable at line 20
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
....).
in Configurable at line 32
mixed
stat(string $name)
deprecated
deprecated 5.0 Use ->config()->get() instead
Get inherited config value
in Configurable at line 44
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
in Configurable at line 57
$this
set_stat(string $name, mixed $value)
deprecated
deprecated 5.0 Use ->config()->set() instead
Update the config value for a given property
in DBConnector at line 76
bool
isQueryMutable(string $sql)
Determine if this SQL statement is a destructive operation (write or ddl)
in DBConnector at line 91
bool
isQueryDDL(string $sql)
Determine if this SQL statement is a DDL operation
in DBConnector at line 104
bool
isQueryWrite(string $sql)
Determine if this SQL statement is a write operation (alters content but not structure)
at line 137
connect(array $parameters, boolean $selectDB = false)
Link this connector to the database given the specified parameters Will throw an exception rather than return a success state.
The connector should not select the database once connected until explicitly called by selectDatabase()
at line 270
string
getVersion()
Query for the version of the currently connected database
at line 275
string
escapeString(string $value)
Given a value escape this for use in a query for the current database connector. Note that this does not quote the value.
at line 287
string
quoteString(string $value)
Given a value escape and quote this appropriately for the current database connector.
at line 333
query(string $sql, integer $errorLevel = E_USER_ERROR)
Executes the following query with the specified error level.
Implementations of this function should respect previewWrite and benchmarkQuery
at line 408
Query
preparedQuery(string $sql, array $parameters, int $errorLevel = E_USER_ERROR)
Execute the given SQL parameterised query with the specified arguments
at line 505
boolean
selectDatabase(string $name)
Select a database by name
at line 512
string
getSelectedDatabase()
Retrieves the name of the currently selected database
at line 517
unloadDatabase()
De-selects the currently selected database
at line 481
string
getLastError()
Retrieves the last error generated from the database connection
at line 495
integer
getGeneratedID(string $table)
Determines the last ID generated from the specified table.
Note that some connectors may not be able to return $table specific responses, and this parameter may be ignored.
at line 500
integer
affectedRows()
Determines the number of affected rows from the last SQL query
at line 522
boolean
isActive()
Determines if we are connected to a server AND have a valid database selected.
at line 92
flushStatements()
Flush all prepared statements
at line 104
PDOStatementHandle|false
getOrPrepareStatement(string $sql)
Retrieve a prepared statement for a given SQL string, or return an already prepared version if one exists for the given query
at line 132
static boolean
is_emulate_prepare()
Is PDO running in emulated mode
at line 265
string
getDriver()
Return the driver for this connector E.g. 'mysql', 'sqlsrv', 'pgsql'
at line 317
int
exec(string $sql, integer $errorLevel = E_USER_ERROR)
Executes a query that doesn't return a resultset
at line 353
integer
getPDOParamType(string $phpType)
Determines the PDO::PARAM_* type for a given PHP type string
at line 383
bindParameters(PDOStatement $statement, array $parameters)
Bind all parameters to a PDOStatement
at line 527
bool
transactionStart(string|boolean $transactionMode = false, string|boolean $sessionCharacteristics = false)
Start a prepared transaction
at line 544
bool
transactionEnd()
Complete a transaction
at line 550
bool
transactionRollback(string $savepoint = null)
Roll-back a transaction
at line 564
int
transactionDepth()
Return the depth of the transaction For unnested transactions returns 1 while in a transaction, 0 otherwise
at line 569
transactionSavepoint(string $savepoint = null)
Create a new savepoint
at line 578
boolean
supportsSavepoints()
Return true if savepoints are supported by this transaction manager.
Savepoints aren't supported by all database connectors (notably PDO doesn't support them) and should be used with caution.