DbConnection
in
Represents a connection to a database service.
Table of Contents
Methods
- beginTransaction() : DbTransaction
- Begins a transaction.
- execute() : int|string
- Executes a statement and returns how many rows are affected.
- getAffectedRows() : int|string
- Gets the number of rows affected by the last operation.
- getLastInsertId() : int|string
- Returns the ID of the last inserted row.
- prepare() : DbStatement
- Prepares a statement for execution and returns a database statement instance.
- query() : DbResult
- Executes a statement and returns a database result instance.
Methods
beginTransaction()
Begins a transaction.
public
beginTransaction() : DbTransaction
Tags
Return values
DbTransactionexecute()
Executes a statement and returns how many rows are affected.
public
execute(string $query) : int|string
Does not request results back from the database and thus should have better performance if the consumer doesn't care about them.
Parameters
- $query : string
-
SQL query to execute.
Return values
int|string —Number of rows affected by the query.
getAffectedRows()
Gets the number of rows affected by the last operation.
public
getAffectedRows() : int|string
Return values
int|string —Number of rows affected by the last operation.
getLastInsertId()
Returns the ID of the last inserted row.
public
getLastInsertId() : int|string
Return values
int|string —Last inserted ID.
prepare()
Prepares a statement for execution and returns a database statement instance.
public
prepare(string $query) : DbStatement
The statement should use question mark (?) parameters.
Parameters
- $query : string
-
SQL query to prepare.
Return values
DbStatement —An instance of an implementation of DbStatement.
query()
Executes a statement and returns a database result instance.
public
query(string $query) : DbResult
Parameters
- $query : string
-
SQL query to execute.
Return values
DbResult —An instance of an implementation of DbResult