Pdo
extends AbstractAdapter
in package
PDO database adapter class
Tags
Table of Contents
- $connection : mixed
- Database connection object/resource
- $dsn : string
- PDO DSN
- $error : mixed
- Error string/object/resource
- $listener : CallableObject
- Query listener object/resource
- $options : mixed
- Database connection options
- $placeholder : string
- Statement placeholder
- $profiler : Profiler
- Query profiler
- $result : mixed
- Result object/resource
- $statement : mixed
- Statement object/resource
- $statementResult : bool
- Statement result
- $type : string
- PDO type
- __construct() : mixed
- Constructor
- beginTransaction() : Pdo
- Begin a transaction
- bindColumn() : Pdo
- Bind a column to a PHP variable.
- bindParam() : Pdo
- Bind a parameter for a prepared SQL query
- bindParams() : Pdo
- Bind parameters to a prepared SQL query
- bindValue() : Pdo
- Bind a value for a prepared SQL query
- clearError() : AbstractAdapter
- Clear the error
- clearProfiler() : AbstractAdapter
- Clear query profiler
- closeCursor() : bool
- Method closes the cursor, translating the request in the ready state.
- commit() : Pdo
- Commit a transaction
- connect() : Pdo
- Connect to the database
- createSchema() : Schema
- Create Schema builder
- createSql() : Sql
- Create SQL builder
- dbFileExists() : bool
- Does the database file exist
- debugDumpParams() : string
- The method displays information about the prepared SQL command for debugging purposes.
- disconnect() : void
- Disconnect from the database
- escape() : string
- Escape the value
- exec() : Pdo
- The method runs an SQL query for execution and returns the number of rows affected during execution.
- execute() : Pdo
- Execute a prepared SQL query
- fetch() : array<string|int, mixed>
- Fetch and return a row from the result
- fetchAll() : array<string|int, mixed>
- Fetch and return all rows from the result
- fetchColumn() : mixed
- The method receives data of one column from the next row of the result set.
- getAttribute() : string
- The method of obtaining the value of the request attribute PDO.
- getConnection() : mixed
- Get the connection object/resource
- getCountOfFields() : int
- The method returns the number of columns in the result set.
- getCountOfRows() : int
- The method returns the number of rows modified by the last SQL query.
- getDsn() : string
- Return the DSN
- getError() : mixed
- Get the error
- getLastId() : int
- Return the last ID of the last query
- getListener() : CallableObject
- Get query listener
- getNumberOfFields() : int
- Return the number of fields in the result.
- getNumberOfRows() : int
- Return the number of rows from the last query
- getOptions() : array<string|int, mixed>
- Get database connection options
- getProfiler() : Profiler
- Get query profiler
- getResult() : mixed
- Get the result object/resource
- getStatement() : mixed
- Get the statement object/resource
- getTables() : array<string|int, mixed>
- Return the tables in the database
- getType() : string
- Return the type
- getVersion() : string
- Return the database version
- hasError() : bool
- Determine whether or not there is an error
- hasOptions() : bool
- Has database connection options
- hasResult() : bool
- Determine whether or not a result resource exists
- hasStatement() : bool
- Determine whether or not a statement resource exists
- hasTable() : bool
- Return if the database has a table
- inTransaction() : bool
- Method checks, whether the transaction is initiated.
- isConnected() : bool
- Determine whether or not connected
- listen() : mixed
- Add query listener to the adapter
- prepare() : Pdo
- Prepare a SQL query
- query() : Pdo
- Execute a SQL query directly
- rollback() : Pdo
- Rollback a transaction
- setAttribute() : bool
- Method sets the value of the request attribute PDO.
- setError() : AbstractAdapter
- Set the error
- setOptions() : Pdo
- Set database connection options
- setProfiler() : AbstractAdapter
- Set query profiler
- throwError() : void
- Throw a database error exception
- buildError() : Pdo
- Build the error
- getErrorMessage() : string
- Get the error message
Properties
$connection
Database connection object/resource
protected
mixed
$connection
= null
$dsn
PDO DSN
protected
string
$dsn
= null
$error
Error string/object/resource
protected
mixed
$error
= null
$listener
Query listener object/resource
protected
CallableObject
$listener
= null
$options
Database connection options
protected
mixed
$options
= []
$placeholder
Statement placeholder
protected
string
$placeholder
= null
$profiler
Query profiler
protected
Profiler
$profiler
= null
$result
Result object/resource
protected
mixed
$result
= null
$statement
Statement object/resource
protected
mixed
$statement
= null
$statementResult
Statement result
protected
bool
$statementResult
= false
$type
PDO type
protected
string
$type
= null
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Instantiate the database connection object using PDO
Parameters
- $options : array<string|int, mixed> = []
Return values
mixed —beginTransaction()
Begin a transaction
public
beginTransaction() : Pdo
Return values
Pdo —bindColumn()
Bind a column to a PHP variable.
public
bindColumn(mixed $column, mixed $param[, int $dataType = PDO::PARAM_STR ]) : Pdo
Parameters
- $column : mixed
-
Number of the column (1-indexed) or name of the column in the result set.
- $param : mixed
-
Name of the PHP variable to which the column will be bound.
- $dataType : int = PDO::PARAM_STR
-
Data type of the parameter, specified by the PDO::PARAM_* constants.
Return values
Pdo —bindParam()
Bind a parameter for a prepared SQL query
public
bindParam(mixed $param, mixed &$value[, int $dataType = PDO::PARAM_STR ][, int $length = null ][, mixed $options = null ]) : Pdo
Parameters
- $param : mixed
- $value : mixed
- $dataType : int = PDO::PARAM_STR
- $length : int = null
- $options : mixed = null
Return values
Pdo —bindParams()
Bind parameters to a prepared SQL query
public
bindParams(array<string|int, mixed> $params) : Pdo
Parameters
- $params : array<string|int, mixed>
Return values
Pdo —bindValue()
Bind a value for a prepared SQL query
public
bindValue(mixed $param, mixed $value[, int $dataType = PDO::PARAM_STR ]) : Pdo
Parameters
- $param : mixed
- $value : mixed
- $dataType : int = PDO::PARAM_STR
Return values
Pdo —clearError()
Clear the error
public
clearError() : AbstractAdapter
Return values
AbstractAdapter —clearProfiler()
Clear query profiler
public
clearProfiler() : AbstractAdapter
Return values
AbstractAdapter —closeCursor()
Method closes the cursor, translating the request in the ready state.
public
closeCursor() : bool
Return values
bool —commit()
Commit a transaction
public
commit() : Pdo
Return values
Pdo —connect()
Connect to the database
public
connect([array<string|int, mixed> $options = [] ]) : Pdo
Parameters
- $options : array<string|int, mixed> = []
Return values
Pdo —createSchema()
Create Schema builder
public
createSchema() : Schema
Return values
Schema —createSql()
Create SQL builder
public
createSql() : Sql
Return values
Sql —dbFileExists()
Does the database file exist
public
dbFileExists() : bool
Return values
bool —debugDumpParams()
The method displays information about the prepared SQL command for debugging purposes.
public
debugDumpParams([bool $debug = false ]) : string
Parameters
- $debug : bool = false
Return values
string —disconnect()
Disconnect from the database
public
disconnect() : void
Return values
void —escape()
Escape the value
public
escape(string $value) : string
Parameters
- $value : string
Return values
string —exec()
The method runs an SQL query for execution and returns the number of rows affected during execution.
public
exec(string $sql) : Pdo
Parameters
- $sql : string
-
The SQL statement to be prepared and run
Return values
Pdo —execute()
Execute a prepared SQL query
public
execute() : Pdo
Return values
Pdo —fetch()
Fetch and return a row from the result
public
fetch([int $dataType = PDO::FETCH_ASSOC ]) : array<string|int, mixed>
Parameters
- $dataType : int = PDO::FETCH_ASSOC
-
Data type of the parameter, specified by the PDO::PARAM_* constants.
Return values
array<string|int, mixed> —fetchAll()
Fetch and return all rows from the result
public
fetchAll([int $dataType = PDO::FETCH_ASSOC ]) : array<string|int, mixed>
Parameters
- $dataType : int = PDO::FETCH_ASSOC
-
Data type of the parameter, specified by the PDO::PARAM_* constants.
Return values
array<string|int, mixed> —fetchColumn()
The method receives data of one column from the next row of the result set.
public
fetchColumn([int $num = null ]) : mixed
Parameters
- $num : int = null
-
The number of the table column
Return values
mixed —getAttribute()
The method of obtaining the value of the request attribute PDO.
public
getAttribute(int $attribute) : string
Parameters
- $attribute : int
-
A request attribute
Return values
string —getConnection()
Get the connection object/resource
public
getConnection() : mixed
Return values
mixed —getCountOfFields()
The method returns the number of columns in the result set.
public
getCountOfFields() : int
Return values
int —getCountOfRows()
The method returns the number of rows modified by the last SQL query.
public
getCountOfRows() : int
Return values
int —getDsn()
Return the DSN
public
getDsn() : string
Return values
string —getError()
Get the error
public
getError() : mixed
Return values
mixed —getLastId()
Return the last ID of the last query
public
getLastId() : int
Return values
int —getListener()
Get query listener
public
getListener() : CallableObject
Return values
CallableObject —getNumberOfFields()
Return the number of fields in the result.
public
getNumberOfFields() : int
Tags
Return values
int —getNumberOfRows()
Return the number of rows from the last query
public
getNumberOfRows() : int
Return values
int —getOptions()
Get database connection options
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getProfiler()
Get query profiler
public
getProfiler() : Profiler
Return values
Profiler —getResult()
Get the result object/resource
public
getResult() : mixed
Return values
mixed —getStatement()
Get the statement object/resource
public
getStatement() : mixed
Return values
mixed —getTables()
Return the tables in the database
public
getTables() : array<string|int, mixed>
Return values
array<string|int, mixed> —getType()
Return the type
public
getType() : string
Return values
string —getVersion()
Return the database version
public
getVersion() : string
Return values
string —hasError()
Determine whether or not there is an error
public
hasError() : bool
Return values
bool —hasOptions()
Has database connection options
public
hasOptions() : bool
Return values
bool —hasResult()
Determine whether or not a result resource exists
public
hasResult() : bool
Return values
bool —hasStatement()
Determine whether or not a statement resource exists
public
hasStatement() : bool
Return values
bool —hasTable()
Return if the database has a table
public
hasTable(string $table) : bool
Parameters
- $table : string
Return values
bool —inTransaction()
Method checks, whether the transaction is initiated.
public
inTransaction() : bool
Return values
bool —isConnected()
Determine whether or not connected
public
isConnected() : bool
Return values
bool —listen()
Add query listener to the adapter
public
listen(mixed $listener[, mixed $params = null ][, Profiler $profiler = null ]) : mixed
Parameters
- $listener : mixed
- $params : mixed = null
- $profiler : Profiler = null
Return values
mixed —prepare()
Prepare a SQL query
public
prepare(mixed $sql[, array<string|int, mixed> $attribs = null ]) : Pdo
Parameters
- $sql : mixed
- $attribs : array<string|int, mixed> = null
Return values
Pdo —query()
Execute a SQL query directly
public
query(mixed $sql) : Pdo
Parameters
- $sql : mixed
Return values
Pdo —rollback()
Rollback a transaction
public
rollback() : Pdo
Return values
Pdo —setAttribute()
Method sets the value of the request attribute PDO.
public
setAttribute(int $attribute, mixed $value) : bool
Parameters
- $attribute : int
-
A request attribute
- $value : mixed
-
The value of the attribute request
Return values
bool —setError()
Set the error
public
setError(string $error) : AbstractAdapter
Parameters
- $error : string
Return values
AbstractAdapter —setOptions()
Set database connection options
public
setOptions(array<string|int, mixed> $options) : Pdo
Parameters
- $options : array<string|int, mixed>
Return values
Pdo —setProfiler()
Set query profiler
public
setProfiler(Profiler $profiler) : AbstractAdapter
Parameters
- $profiler : Profiler
Return values
AbstractAdapter —throwError()
Throw a database error exception
public
throwError([string $error = null ]) : void
Parameters
- $error : string = null
Tags
Return values
void —buildError()
Build the error
protected
buildError([string $code = null ][, array<string|int, mixed> $info = null ]) : Pdo
Parameters
- $code : string = null
- $info : array<string|int, mixed> = null
Return values
Pdo —getErrorMessage()
Get the error message
protected
getErrorMessage(mixed $errorInfo) : string
Parameters
- $errorInfo : mixed