PDOConnector deprecated
class PDOConnector extends DBConnector implements TransactionManager (View source)
deprecated
PDO driver database connector
Traits
Provides extensions to this object to integrate it with standard config API methods.
Config options
| write_operations | array | List of operations to treat as write Implicitly includes all ddl_operations  | 
                from DBConnector | 
| ddl_operations | array | List of operations to treat as DDL  | 
                from DBConnector | 
| emulate_prepare | bool | Should ATTR_EMULATE_PREPARES flag be used to emulate prepared statements?  | 
                |
| legacy_types | bool | 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  | 
                
Properties
| protected | PDO | $pdoConnection | The PDO connection instance  | 
                |
| protected | string | $databaseName | Name of the currently selected database  | 
                |
| protected | int|null | $rowCount | If available, the row count of the last executed statement  | 
                |
| protected | array|null | $lastStatementError | Error generated by the errorInfo() method of the last PDOStatement  | 
                |
| protected | array | $cachedStatements | List of prepared statements, cached by SQL string  | 
                |
| protected | string | $driver | Driver | |
| protected | $inTransaction | 
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
Error handler for database errors.
Determine if this SQL statement is a destructive operation (write or ddl)
Determine if this SQL statement is a DDL operation
Determine if this SQL statement is a write operation (alters content but not structure)
Determine if a query is of the given type
Extracts only the parameter values for error reporting
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
Determines if we are connected to a server AND have a valid database selected.
Retrieve a prepared statement for a given SQL string, or return an already prepared version if one exists for the given query
Executes a query that doesn't return a resultset
Determines the PDO::PARAM_* type for a given PHP type string
Given a PDOStatement that has just been executed, generate results and report any errors
Start a prepared transaction
Return the depth of the transaction For unnested transactions returns 1 while in a transaction, 0 otherwise
Return true if savepoints are supported by this transaction manager.
Details
        
                static            Config_ForClass
    config()
        
    
    Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
        
                            mixed
    stat(string $name)
        deprecated
    
    deprecated
Get inherited config value
        
                            mixed
    uninherited(string $name)
        
    
    Gets the uninherited value for the given config option
        
                            $this
    set_stat(string $name, mixed $value)
        deprecated
    
    deprecated
Update the config value for a given property
        
                    protected        
    databaseError(string $msg, int $errorLevel = E_USER_ERROR, string $sql = null, array $parameters = [])
        
    
    Error handler for database errors.
All database errors will call this function to report the error. It isn't a static function; it will be called on the object itself and as such can be overridden in a subclass. Subclasses should run all errors through this function.
        
                            bool
    isQueryMutable(string $sql)
        
    
    Determine if this SQL statement is a destructive operation (write or ddl)
        
                            bool
    isQueryDDL(string $sql)
        
    
    Determine if this SQL statement is a DDL operation
        
                            bool
    isQueryWrite(string $sql)
        
    
    Determine if this SQL statement is a write operation (alters content but not structure)
        
                    protected        bool
    isQueryType(string $sql, string|array $type)
        
    
    Determine if a query is of the given type
        
                    protected        array
    parameterValues(array $parameters)
        
    
    Extracts only the parameter values for error reporting
        
                            
    connect(array $parameters, bool $selectDB = false)
        deprecated
    
    deprecated
No description
        
                            string
    getVersion()
        
    
    Query for the version of the currently connected database
        
                            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.
        
                            string
    quoteString(string $value)
        
    
    Given a value escape and quote this appropriately for the current database connector.
        
                            
    query(string $sql, int $errorLevel = E_USER_ERROR)
        
    
    Executes the following query with the specified error level.
Implementations of this function should respect previewWrite and benchmarkQuery
        
                            Query
    preparedQuery(string $sql, array $parameters, int $errorLevel = E_USER_ERROR)
        
    
    Execute the given SQL parameterised query with the specified arguments
        
                            bool
    selectDatabase(string $name)
        
    
    Select a database by name
        
                            string
    getSelectedDatabase()
        
    
    Retrieves the name of the currently selected database
        
                            
    unloadDatabase()
        
    
    De-selects the currently selected database
        
                            string
    getLastError()
        
    
    Retrieves the last error generated from the database connection
        
                            int
    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.
        
                            int
    affectedRows()
        
    
    Determines the number of affected rows from the last SQL query
        
                            bool
    isActive()
        
    
    Determines if we are connected to a server AND have a valid database selected.
        
                            
    __construct()
        
    
    No description
        
                            
    flushStatements()
        
    
    Flush all prepared statements
        
                            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
        
                static            bool
    is_emulate_prepare()
        
    
    Is PDO running in emulated mode
        
                            string
    getDriver()
        
    
    Return the driver for this connector E.g. 'mysql', 'sqlsrv', 'pgsql'
        
                    protected        
    beforeQuery(string $sql)
        
    
    Invoked before any query is executed
        
                            int
    exec(string $sql, int $errorLevel = E_USER_ERROR)
        
    
    Executes a query that doesn't return a resultset
        
                            int
    getPDOParamType(string $phpType)
        
    
    Determines the PDO::PARAM_* type for a given PHP type string
        
                            
    bindParameters(PDOStatement $statement, array $parameters)
        
    
    Bind all parameters to a PDOStatement
        
                    protected        PDOQuery
    prepareResults(PDOStatementHandle $statement, int $errorLevel, string $sql, array $parameters = [])
        
    
    Given a PDOStatement that has just been executed, generate results and report any errors
        
                    protected        bool
    hasError(PDOStatement|PDO $resource)
        
    
    Determine if a resource has an attached error
        
                            bool
    transactionStart(string|bool $transactionMode = false, string|bool $sessionCharacteristics = false)
        
    
    Start a prepared transaction
        
                            bool
    transactionEnd()
        
    
    Complete a transaction
        
                            bool
    transactionRollback(string $savepoint = null)
        
    
    Roll-back a transaction
        
                            int
    transactionDepth()
        
    
    Return the depth of the transaction For unnested transactions returns 1 while in a transaction, 0 otherwise
        
                            
    transactionSavepoint(string $savepoint = null)
        
    
    Create a new savepoint
        
                            bool
    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.