IConnection
interface IConnection (View source)
Provides an interface for connecting to a database.
Methods
Connects to a database interface.
Pings a server connection, or tries to reconnect if the connection has gone down
Disconnects from a database.
Returns true when connection was established.
This method is used to get the database connection instance.
This method is used to assign the database connection instance.
This function creates a new transaction, in order to be able to commit or rollback changes made to the database.
This function commits any changes made to the database during this transaction.
This function rolls back any changes made to the database during this transaction and restores the data to its original state.
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.
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.
This function quotes a string for use in an SQL statement and escapes special characters (such as quotes).
Returns an object containing the number of queried rows and the number of affected rows.
Returns the query string.
Sets the query string for the Connection instance.
Returns the parameters associated with this instance.
Sets the query parameters for the Connection instance.
Returns the number of rows affected by an operation.
Sets the number of query rows for the Connection instance.
Returns the number of columns in a statement result.
Sets the number of columns in the query result.
Returns the number of rows affected by an operation.
Sets the number of affected rows for the Connection instance.
Returns the statement for the function.
Set the statement for the function.
This function prepares an SQL statement for execution and returns a statement object.
This function executes an SQL statement and returns the result set as a statement object.
This function runs an SQL statement and returns the number of affected rows.
Executes the query and returns the result.
Executes the query and returns all the results.
This function retrieves an attribute from the database.
This function sets an attribute from the database.
This function returns an SQLSTATE code for the last operation executed by the database.
This function returns an array containing error information about the last operation performed by the database.
Details
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.