Properties

$connection

$connection : mixed

Database connection object/resource

Type

mixed

$statement

$statement : mixed

Statement object/resource

Type

mixed

$result

$result : mixed

Result object/resource

Type

mixed

$error

$error : mixed

Error string/object/resource

Type

mixed

$dsn

$dsn : string

PDO DSN

Type

string

$type

$type : string

PDO type

Type

string

$placeholder

$placeholder : string

Statement placeholder

Type

string

Methods

__construct()

__construct(array  $options) 

Constructor

Instantiate the database connection object using PDO

Parameters

array $options

beginTransaction()

beginTransaction() : \Pop\Db\Adapter\Pdo

Begin a transaction

Returns

\Pop\Db\Adapter\Pdo

rollback()

rollback() : \Pop\Db\Adapter\Pdo

Rollback a transaction

Returns

\Pop\Db\Adapter\Pdo

query()

query(mixed  $sql) : \Pop\Db\Adapter\Pdo

Execute a SQL query directly

Parameters

mixed $sql

Returns

\Pop\Db\Adapter\Pdo

prepare()

prepare(mixed  $sql, array  $attribs = null) : \Pop\Db\Adapter\Pdo

Prepare a SQL query

Parameters

mixed $sql
array $attribs

Returns

\Pop\Db\Adapter\Pdo

bindParams()

bindParams(array  $params) : \Pop\Db\Adapter\Pdo

Bind parameters to a prepared SQL query

Parameters

array $params

Returns

\Pop\Db\Adapter\Pdo

execute()

execute() : \Pop\Db\Adapter\Pdo

Execute a prepared SQL query

Returns

\Pop\Db\Adapter\Pdo

fetch()

fetch(integer  $dataType = \PDO::FETCH_ASSOC) : array

Fetch and return a row from the result

Parameters

integer $dataType

Data type of the parameter, specified by the PDO::PARAM_* constants.

Returns

array

fetchAll()

fetchAll(integer  $dataType = \PDO::FETCH_ASSOC) : array

Fetch and return all rows from the result

Parameters

integer $dataType

Data type of the parameter, specified by the PDO::PARAM_* constants.

Returns

array

isConnected()

isConnected() : boolean

Determine whether or not connected

Returns

boolean

createSql()

createSql() : \Pop\Db\Sql

Create SQL builder

Returns

\Pop\Db\Sql

createSchema()

createSchema() : \Pop\Db\Sql\Schema

Create Schema builder

Returns

\Pop\Db\Sql\Schema

getConnection()

getConnection() : mixed

Get the connection object/resource

Returns

mixed

hasStatement()

hasStatement() : boolean

Determine whether or not a statement resource exists

Returns

boolean

getStatement()

getStatement() : mixed

Get the statement object/resource

Returns

mixed

hasResult()

hasResult() : boolean

Determine whether or not a result resource exists

Returns

boolean

getResult()

getResult() : mixed

Get the result object/resource

Returns

mixed

hasError()

hasError() : boolean

Determine whether or not there is an error

Returns

boolean

getError()

getError() : mixed

Get the error

Returns

mixed

throwError()

throwError(string  $error = null) : void

Throw a database error exception

Parameters

string $error

Throws

\Pop\Db\Adapter\Exception

disconnect()

disconnect() : void

Disconnect from the database

escape()

escape(string  $value) : string

Escape the value

Parameters

string $value

Returns

string

getLastId()

getLastId() : integer

Return the last ID of the last query

Returns

integer

getNumberOfRows()

getNumberOfRows() : integer

Return the number of rows from the last query

Returns

integer

getVersion()

getVersion() : string

Return the database version

Returns

string

getTables()

getTables() : array

Return the tables in the database

Returns

array

hasTable()

hasTable(string  $table) : boolean

Return if the database has a table

Parameters

string $table

Returns

boolean

getDsn()

getDsn() : string

Return the DSN

Returns

string

getType()

getType() : string

Return the type

Returns

string

inTransaction()

inTransaction() : boolean

Method checks, whether the transaction is initiated.

Returns

boolean

setAttribute()

setAttribute(integer  $attribute, mixed  $value) : boolean

Method sets the value of the request attribute PDO.

Parameters

integer $attribute

A request attribute

mixed $value

The value of the attribute request

Returns

boolean

getAttribute()

getAttribute(integer  $attribute) : string

The method of obtaining the value of the request attribute PDO.

Parameters

integer $attribute

A request attribute

Returns

string

bindParam()

bindParam(mixed  $param, mixed  $value, integer  $dataType = \PDO::PARAM_STR, integer  $length = null, mixed  $options = null) : \Pop\Db\Adapter\Pdo

Bind a parameter for a prepared SQL query

Parameters

mixed $param
mixed $value
integer $dataType
integer $length
mixed $options

Returns

\Pop\Db\Adapter\Pdo

bindValue()

bindValue(mixed  $param, mixed  $value, integer  $dataType = \PDO::PARAM_STR) : \Pop\Db\Adapter\Pdo

Bind a value for a prepared SQL query

Parameters

mixed $param
mixed $value
integer $dataType

Returns

\Pop\Db\Adapter\Pdo

bindColumn()

bindColumn(mixed  $column, mixed  $param, integer  $dataType = \PDO::PARAM_STR) : \Pop\Db\Adapter\Pdo

Bind a column to a PHP variable.

Parameters

mixed $column

Number of the column (1-indexed) or name of the column in the result set.

mixed $param

Name of the PHP variable to which the column will be bound.

integer $dataType

Data type of the parameter, specified by the PDO::PARAM_* constants.

Returns

\Pop\Db\Adapter\Pdo

getNumberOfFields()

getNumberOfFields() : integer

Return the number of fields in the result.

Throws

\Pop\Db\Adapter\Exception

Returns

integer

closeCursor()

closeCursor() : boolean

Method closes the cursor, translating the request in the ready state.

Returns

boolean

getCountOfFields()

getCountOfFields() : integer

The method returns the number of columns in the result set.

Returns

integer

fetchColumn()

fetchColumn(integer  $num = null) : mixed

The method receives data of one column from the next row of the result set.

Parameters

integer $num

The number of the table column

Returns

mixed

getCountOfRows()

getCountOfRows() : integer

The method returns the number of rows modified by the last SQL query.

Returns

integer

debugDumpParams()

debugDumpParams(boolean  $debug = false) : string

The method displays information about the prepared SQL command for debugging purposes.

Parameters

boolean $debug

Returns

string

exec()

exec(string  $sql) : \Pop\Db\Adapter\Pdo

The method runs an SQL query for execution and returns the number of rows affected during execution.

Parameters

string $sql

The SQL statement to be prepared and run

Returns

\Pop\Db\Adapter\Pdo

buildError()

buildError(string  $code = null, array  $info = null) : \Pop\Db\Adapter\Pdo

Build the error

Parameters

string $code
array $info

Throws

\Pop\Db\Adapter\Exception

Returns

\Pop\Db\Adapter\Pdo