interface IConnection (View source)

Provides an interface for connecting to a database.

Methods

mixed
connect()

Connects to a database interface.

bool
ping()

Pings a server connection, or tries to reconnect if the connection has gone down

void
disconnect()

Disconnects from a database.

bool
isConnected()

Returns true when connection was established.

mixed
getConnection()

This method is used to get the database connection instance.

mixed
setConnection(mixed $connection)

This method is used to assign the database connection instance.

bool
beginTransaction()

This function creates a new transaction, in order to be able to commit or rollback changes made to the database.

bool
commit()

This function commits any changes made to the database during this transaction.

bool
rollback()

This function rolls back any changes made to the database during this transaction and restores the data to its original state.

bool
inTransaction()

This function returns the last ID generated by an auto-increment column, either the last one inserted during the current transaction, or by passing in the optional name parameter.

string|int|false
lastInsertId(string|null $name = null)

This function returns the last ID generated by an auto-increment column, either the last one inserted during the current transaction, or by passing in the optional name parameter.

mixed
quote(mixed ...$params)

This function quotes a string for use in an SQL statement and escapes special characters (such as quotes).

object
getAllMetadata()

Returns an object containing the number of queried rows and the number of affected rows.

string
getQueryString()

Returns the query string.

void
setQueryString(string $params)

Sets the query string for the Connection instance.

array|null
getQueryParameters()

Returns the parameters associated with this instance.

void
setQueryParameters(array|null $params)

Sets the query parameters for the Connection instance.

int|false
getQueryRows()

Returns the number of rows affected by an operation.

void
setQueryRows(callable|int|false $params)

Sets the number of query rows for the Connection instance.

int|false
getQueryColumns()

Returns the number of columns in a statement result.

void
setQueryColumns(int|false $params)

Sets the number of columns in the query result.

int|false
getAffectedRows()

Returns the number of rows affected by an operation.

void
setAffectedRows(int|false $params)

Sets the number of affected rows for the Connection instance.

mixed
getStatement()

Returns the statement for the function.

void
setStatement(mixed $statement)

Set the statement for the function.

mixed
prepare(mixed ...$params)

This function prepares an SQL statement for execution and returns a statement object.

mixed
query(mixed ...$params)

This function executes an SQL statement and returns the result set as a statement object.

mixed
exec(mixed ...$params)

This function runs an SQL statement and returns the number of affected rows.

mixed
fetch(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Executes the query and returns the result.

mixed
fetchAll(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Executes the query and returns all the results.

mixed
getAttribute(mixed $name)

This function retrieves an attribute from the database.

void
setAttribute(mixed $name, mixed $value)

This function sets an attribute from the database.

int|string|array|bool|null
errorCode(mixed $inst = null)

This function returns an SQLSTATE code for the last operation executed by the database.

string|array|bool|null
errorInfo(mixed $inst = null)

This function returns an array containing error information about the last operation performed by the database.

Details

mixed connect()

Connects to a database interface.

Return Value

mixed

bool ping()

Pings a server connection, or tries to reconnect if the connection has gone down

Return Value

bool

void disconnect()

Disconnects from a database.

Return Value

void

bool isConnected()

Returns true when connection was established.

Return Value

bool

mixed getConnection()

This method is used to get the database connection instance.

Return Value

mixed

mixed setConnection(mixed $connection)

This method is used to assign the database connection instance.

Parameters

mixed $connection

Sets an instance of the connection with the database

Return Value

mixed

bool beginTransaction()

This function creates a new transaction, in order to be able to commit or rollback changes made to the database.

Return Value

bool

bool commit()

This function commits any changes made to the database during this transaction.

Return Value

bool

bool rollback()

This function rolls back any changes made to the database during this transaction and restores the data to its original state.

Return Value

bool

bool inTransaction()

This function returns the last ID generated by an auto-increment column, either the last one inserted during the current transaction, or by passing in the optional name parameter.

Return Value

bool

string|int|false lastInsertId(string|null $name = null)

This function returns the last ID generated by an auto-increment column, either the last one inserted during the current transaction, or by passing in the optional name parameter.

Parameters

string|null $name

= null Resource name, table or view

Return Value

string|int|false

mixed quote(mixed ...$params)

This function quotes a string for use in an SQL statement and escapes special characters (such as quotes).

Parameters

mixed ...$params

Content to be quoted

Return Value

mixed

object getAllMetadata()

Returns an object containing the number of queried rows and the number of affected rows.

Return Value

object

An associative object with keys 'queryRows' and 'affectedRows'.

string getQueryString()

Returns the query string.

Return Value

string

The query string associated with this instance.

void setQueryString(string $params)

Sets the query string for the Connection instance.

Parameters

string $params

The query string to set.

Return Value

void

array|null getQueryParameters()

Returns the parameters associated with this instance.

Return Value

array|null

The parameters associated with this instance.

void setQueryParameters(array|null $params)

Sets the query parameters for the Connection instance.

Parameters

array|null $params

The query parameters to set.

Return Value

void

int|false getQueryRows()

Returns the number of rows affected by an operation.

Return Value

int|false

The number of affected rows

void setQueryRows(callable|int|false $params)

Sets the number of query rows for the Connection instance.

Parameters

callable|int|false $params

The number of query rows to set.

Return Value

void

int|false getQueryColumns()

Returns the number of columns in a statement result.

Return Value

int|false

The number of columns in the result or false in case of an error.

void setQueryColumns(int|false $params)

Sets the number of columns in the query result.

Parameters

int|false $params

The number of columns or false if there are no columns.

Return Value

void

int|false getAffectedRows()

Returns the number of rows affected by an operation.

Return Value

int|false

The number of affected rows

void setAffectedRows(int|false $params)

Sets the number of affected rows for the Connection instance.

Parameters

int|false $params

The number of affected rows to set.

Return Value

void

mixed getStatement()

Returns the statement for the function.

Return Value

mixed

void setStatement(mixed $statement)

Set the statement for the function.

Parameters

mixed $statement

The statement to be set.

Return Value

void

mixed prepare(mixed ...$params)

This function prepares an SQL statement for execution and returns a statement object.

Parameters

mixed ...$params

Statement to be prepared

Return Value

mixed

mixed query(mixed ...$params)

This function executes an SQL statement and returns the result set as a statement object.

Parameters

mixed ...$params

Statement to be queried

Return Value

mixed

mixed exec(mixed ...$params)

This function runs an SQL statement and returns the number of affected rows.

Parameters

mixed ...$params

Statement to be executed

Return Value

mixed

mixed fetch(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Executes the query and returns the result.

Parameters

int|null $fetchStyle

The fetch style to use.

mixed $fetchArgument

The fetch argument to use.

mixed $optArgs

Additional options for the fetch operation.

Return Value

mixed

The query result.

mixed fetchAll(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Executes the query and returns all the results.

Parameters

int|null $fetchStyle

The fetch style to use.

mixed $fetchArgument

The fetch argument to use.

mixed $optArgs

Additional options for the fetch operation.

Return Value

mixed

The query result.

mixed getAttribute(mixed $name)

This function retrieves an attribute from the database.

Parameters

mixed $name

The attribute name

Return Value

mixed

void setAttribute(mixed $name, mixed $value)

This function sets an attribute from the database.

Parameters

mixed $name

The attribute name

mixed $value

The attribute value

Return Value

void

int|string|array|bool|null errorCode(mixed $inst = null)

This function returns an SQLSTATE code for the last operation executed by the database.

Parameters

mixed $inst

= null Resource name, table or view

Return Value

int|string|array|bool|null

string|array|bool|null errorInfo(mixed $inst = null)

This function returns an array containing error information about the last operation performed by the database.

Parameters

mixed $inst

= null Resource name, table or view

Return Value

string|array|bool|null