MySqlConnection
class MySqlConnection implements Connection (View source)
Provides the basic functionality to operate on a MySQL database.
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.
Returns a comma separated list of escaped field names from given table aliased with given prefix.
Returns an escaped table name aliased to the given alias.
Executes an arbitrary SQL query in the database.
Details
at line 22
__construct(ConnectionProvider $provider)
MySqlConnection constructor.
at line 32
PDOStatement
insert(string $table, array $values, string|null $primaryKey = null)
Inserts a row the database with given column values.
at line 47
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 65
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 86
string
formatFields(array $fields, string $table = '', string $prefix = '')
Returns a comma separated list of escaped field names from given table aliased with given prefix.
at line 112
string
formatTable(string $table, string $alias = '')
Returns an escaped table name aliased to the given alias.
at line 297
PDOStatement
query(string $sql, array $parameters = [])
Executes an arbitrary SQL query in the database.