Connection
interface Connection (View source)
Interface for database connections that provide basic query functionality to an SQL database.
Constants
ORDER_ASCENDING |
Ascending sorting order for select queries. |
ORDER_DESCENDING |
Descending sorting order for select queries. |
Methods
Returns the underlying PDO connection to the database.
Inserts a row the database with given column values.
Selects rows from the database.
Updates rows in the database.
Deletes rows from the database.
Executes an arbitrary SQL query in the database.
Returns an escaped table name aliased to the given alias.
Returns a comma separated list of escaped field names from given table aliased with given prefix.
Details
at line 32
PDOStatement
insert(string $table, array $values, string|null $primaryKey = null)
Inserts a row the database with given column values.
at line 53
PDOStatement
select(array $fields, string $table, array $where, array $orderBy = [], int $limit = null)
Selects rows from the database.
The conditions provided to the query must be an associative array of columns and expected values. Any scalar value and null are supported for equal comparison. If an array is provided as an value for the column, then the value must by any of the provided values in the array, i.e. an "IN" SQL comparison. Null is also supported as one of the values in the array.
The sorting order provides list of columns to sort by in order of importance with the appropriate sorting direction. Note that the limit argument is ignore if no sorting columns have been provided, as the order of rows is undefined.
at line 68
PDOStatement
update(string $table, array $values, array $where)
Updates rows in the database.
at line 76
PDOStatement
delete(string $table, array $where)
Deletes rows from the database.
at line 84
PDOStatement
query(string $sql, array $parameters = [])
Executes an arbitrary SQL query in the database.
at line 92
string
formatTable(string $table, string $alias = '')
Returns an escaped table name aliased to the given alias.
at line 101
string
formatFields(array $fields, string $table = '', string $prefix = '')
Returns a comma separated list of escaped field names from given table aliased with given prefix.