fyre / db
A database library.
Installs: 424
Dependents: 5
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
pkg:composer/fyre/db
Requires
- fyre/config: ^5.0
- fyre/container: ^2.0
- fyre/datetime: ^4.0
- fyre/event: ^5.0
- fyre/log: ^7.0
- fyre/macro: ^2.0
- fyre/typeparser: ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- fyre/php-cs-fixer-config: ^1.0
- phpunit/phpunit: ^12
- dev-main
- v7.0
- v6.3.4
- v6.3.3
- v6.3.2
- v6.3.1
- v6.3.0
- v6.2.5
- v6.2.4
- v6.2.3
- v6.2.2
- v6.2.1
- v6.2.0
- v6.1.2
- v6.1.1
- v6.1.0
- v6.0.2
- v6.0.1
- v6.0
- v5.0.1
- v5.0
- v4.2.1
- v4.2.0
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0
- v1.3.1
- v1.3.0
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.11
- v1.1.10
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0
This package is auto-updated.
Last update: 2025-10-29 08:53:21 UTC
README
FyreDB is a free, open-source database library for PHP.
Table Of Contents
Installation
Using Composer
composer require fyre/db
In PHP:
use Fyre\DB\ConnectionManager;
Basic Usage
$connectionManager = new ConnectionManager($container, $config);
Default configuration options will be resolved from the "Database" key in the Config.
Autoloading
It is recommended to bind the ConnectionManager to the Container as a singleton.
$container->singleton(ConnectionManager::class);
Any dependencies will be injected automatically when loading from the Container.
$connectionManager = $container->use(ConnectionManager::class);
Methods
Build
Build a Connection.
$optionsis an array containing configuration options.
$connection = $connectionManager->build($options);
Connection dependencies will be resolved automatically from the Container.
Clear
Clear and close connections.
$connectionManager->clear();
Get Config
Set a Connection config.
$keyis a string representing the Connection key.
$config = $connectionManager->getConfig($key);
Alternatively, if the $key argument is omitted an array containing all configurations will be returned.
$config = $connectionManager->getConfig();
Has Config
Determine whether a Connection config exists.
$keyis a string representing the Connection key, and will default toConnectionManager::DEFAULT.
$hasConfig = $connectionManager->hasConfig($key);
Is Loaded
Determine whether a Connection instance is loaded.
$keyis a string representing the Connection key, and will default toConnectionManager::DEFAULT.
$isLoaded = $connectionManager->isLoaded($key);
Set Config
Set the Connection config.
$keyis a string representing the Connection key.$optionsis an array containing configuration options.
$connectionManager->setConfig($key, $options);
Unload
Unload a Connection.
$keyis a string representing the Connection key, and will default toConnectionManager::DEFAULT.
$connectionManager->unload($key);
Use
Load a shared Connection instance.
$keyis a string representing the Connection key, and will default toConnectionManager::DEFAULT.
$connection = $connectionManager->use($key);
Connection dependencies will be resolved automatically from the Container.
Connections
You can load a specific connection handler by specifying the className option of the $options variable above.
Custom connection handlers can be created by extending \Fyre\DB\Connection, ensuring all below methods are implemented.
Custom handlers should also implement a generator method that returns a new QueryGenerator (if required) and a resultSetClass static method that returns the class name to use for results.
Affected Rows
Get the number of affected rows.
$affectedRows = $connection->affectedRows();
After Commit
Queue a callback to execute after the transaction is committed.
$callbackis a Closure.$priorityis a number representing the callback priority, and will default to 1.$keyis a string representing a unique identifier for the callback, and will default to null.
$connection->afterCommit($callback, $priority, $key);
The callback will be executed immediately if there is no active transaction.
Begin
Begin a transaction.
$connection->begin();
Commit
Commit a transaction.
$connection->commit();
Connect
Connect to the database.
$connection->connect();
This method is called automatically when the Connection is created.
Delete
Create a DeleteQuery.
$aliasis a string or array containing the table aliases to delete, and will default to null.
$query = $connection->delete($alias);
Disable Foreign Keys
Disable foreign key checks.
$connection->disableForeignKeys();
Disable Query Logging
Disable query logging.
$connection->disableQueryLogging();
Disconnect
Disconnect from the database.
$connection->disconnect();
Enable Foreign Keys
Enable foreign key checks.
$connection->enableForeignKeys();
Enable Query Logging
Enable query logging.
$connection->enableQueryLogging();
Execute
Execute a SQL query with bound parameters.
$sqlis a string representing the SQL query.$paramsis an array containing the bound parameters.
$result = $connection->execute($sql, $params);
The SQL query can use either ? as a placeholder (for numerically indexed parameters), or the array key prefixed with :.
This method will return a ResultSet for SELECT queries. Other query types will return a boolean value.
Get Charset
Get the connection character set.
$charset = $connection->getCharset();
Get Error
Get the last connection error.
$error = $connection->getError();
Get Savepoint Level
Get the transaction save point level.
$savePointLevel = $connection->getSavePointLevel();
In Transaction
Determine whether a transaction is in progress.
$inTransaction = $connection->inTransaction();
Insert
Create an InsertQuery.
$query = $connection->insert();
Insert From
Create an InsertFromQuery.
$fromis a Closure, SelectQuery, QueryLiteral or string representing the query.$columnsis an array of column names.
$query = $connection->insertFrom($from, $columns);
Insert ID
Get the last inserted ID.
$id = $connection->insertId();
When performing bulk inserts, this method will return the first ID for MySQL connections, and the last ID for Postgres and Sqlite.
Literal
Create a QueryLiteral.
$stringis a string representing the literal string.
$literal = $connection->literal($string);
Query
Execute a SQL query.
$sqlis a string representing the SQL query.
$result = $connection->query($sql);
This method will return a ResultSet for SELECT queries. Other query types will return a boolean value.
Quote
Quote a string for use in SQL queries.
$valueis a string representing the value to quote.
$quoted = $connection->quote($value);
Replace
Create a ReplaceQuery.
$query = $connection->replace();
This method is only supported for queries using a MysqlConnection or SqliteConnection.
Rollback
Rollback a transaction.
$connection->rollback();
Select
Create a SelectQuery.
$fieldsis an array or string representing the fields to select, and will default to "*".
$query = $connection->select($fields);
Non-numeric array keys will be used as field aliases.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Set Charset
Set the connection character set.
$charsetis a string representing the connection character set.
$connection->setCharset($charset);
Transactional
Execute a callback inside a database transaction.
$callbackis a Closure that will be executed inside the transaction.
$result = $connection->transactional($callback);
If the callback returns false or throws an Exception the transaction will be rolled back, otherwise it will be committed.
Truncate
Truncate a table.
$tableNameis a string representing the table name.
$connection->truncate($tableName);
Update
Create an UpdateQuery.
$tableis an array or string representing the table(s).
$query = $connection->update($table);
Non-numeric array keys will be used as table aliases.
Update Batch
Create an UpdateBatchQuery.
$tableis an array or string representing the table(s).
$query = $connection->updateBatch($table);
Non-numeric array keys will be used as table aliases.
Version
Get the server version.
$version = $connection->version();
MySQL
The MySQL connection can be loaded using custom configuration.
$optionsis an array containing configuration options.classNamemust be set to\Fyre\DB\Handlers\Mysql\MysqlConnection.hostis a string representing the MySQL host, and will default to "127.0.0.1".usernameis a string representing the MySQL username.passwordis a string representing the MySQL password.databaseis a string representing the MySQL database.portis a number indicating the MySQL port, and will default to 3306.collationis a string representing the collation, and will default to "utf8mb4_unicode_ci".charsetis a string representing the character set, and will default to "utf8mb4".compressis a boolean indicating whether to enable compression, and will default to false.persistis a boolean indicating whether to use a persistent connection, and will default to false.timeoutis a number indicating the connection timeout.sslis an array containing SSL options.keyis a string representing the path to the key file.certis a string representing the path to the certificate file.cais a string representing the path to the certificate authority file.capathis a string representing the path to a directory containing CA certificates.cipheris a string representing a list of allowable ciphers to use for encryption.
flagsis an array containing PDO connection options.logis a boolean indicating whether to log queries, and will default to false.
$container->use(Config::class)->set('Database.mysql', $options);
Get Collation
Get the connection collation.
$collation = $connection->getCollation();
Postgres
The Postgres connection can be loaded using custom configuration.
$optionsis an array containing configuration options.classNamemust be set to\Fyre\DB\Handlers\Postgres\PostgresConnection.hostis a string representing the Postgres host, and will default to "127.0.0.1".usernameis a string representing the Postgres username.passwordis a string representing the Postgres password.databaseis a string representing the Postgres database.portis a number indicating the Postgres port, and will default to 5432.charsetis a string representing the character set, and will default to "utf8".schemais a string representing the character set, and will default to "public".persistis a boolean indicating whether to use a persistent connection, and will default to false.timeoutis a number indicating the connection timeout.flagsis an array containing PDO connection options.logis a boolean indicating whether to log queries, and will default to false.
$container->use(Config::class)->set('Database.postgres', $options);
Set Schema
Set the connection schema.
$schemais a string representing the connection schema.
$connection->setSchema($schema);
Sqlite
The Sqlite connection can be loaded using custom configuration.
$optionsis an array containing configuration options.classNamemust be set to\Fyre\DB\Handlers\Sqlite\SqliteConnection.databaseis a string representing the Sqlite database file, and will default to ":memory:".maskis a number indicating the database file permissions, and will default to 0644.cacheis a string representing the cache flag.modeis a string representing the mode flag.persistis a boolean indicating whether to use a persistent connection, and will default to false.flagsis an array containing PDO connection options.logis a boolean indicating whether to log queries, and will default to false.
$container->use(Config::class)->set('Database.sqlite', $options);
Queries
The \Fyre\DB\Query class provides base methods related to building queries, and is extended by the query type classes below.
Execute
Execute the query.
$result = $query->execute();
This method will return a ResultSet for SELECT queries. Other query types will return a boolean value.
Connection
Get the Connection.
$connection = $query->getConnection();
Get Table
Get the table(s).
$table = $query->getTable();
Sql
Generate the SQL query.
$sql = $query->sql();
Table
Set the table(s).
$tableis an array or string representing the table(s).$overwriteis a boolean indicating whether to overwrite existing tables, and will default to false.
$query->table($table, $overwrite);
Non-numeric array keys will be used as table aliases.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection.
Delete
The \Fyre\DB\Queries\DeleteQuery class extends the Query class, while providing additional methods for executing DELETE queries.
$connection ->delete($alias) ->from($table) ->where($conditions) ->execute();
Multiple tables is only supported for queries using a MysqlConnection.
Alias
Set the delete alias(es).
$aliasis a string or array containing the table aliases to delete, and will default to null.$overwriteis a boolean indicating whether to overwrite existing aliases, and will default to false.
$query->alias($alias, $overwrite);
This method is only supported for queries using a MysqlConnection.
Epilog
Set the epilog.
$epilogis a string representing the epilog for the query.
$query->epilog($epilog);
From
Set the FROM table(s).
$tableis an array or string representing the table(s).$overwriteis a boolean indicating whether to overwrite existing tables, and will default to false.
$query->from($table, $overwrite);
Non-numeric array keys will be used as table aliases.
Get Alias
Get the delete alias(es).
$alias = $query->getAlias();
Get Epilog
Get the epilog.
$epilog = $query->getEpilog();
Get From
Get the FROM table(s).
$table = $query->getFrom();
Get Join
Get the JOIN tables.
$joins = $query->getJoin();
Get Limit
Get the LIMIT clause.
$limit = $query->getLimit();
Get Order By
Get the ORDER BY fields.
$orderBy = $query->getOrderBy();
Get Using
Get the USING tables.
$table = $query->getUsing();
Get Where
Get the WHERE conditions.
$conditions = $query->getWhere();
Join
Set the JOIN tables.
$joinsis a 2-dimensional array of joins.$overwriteis a boolean indicating whether to overwrite existing joins, and will default to false.
$query->join($joins, $overwrite);
Each join array can contain a table, alias, type and an array of conditions. If the type is not specified it will default to INNER.
This method is only supported for queries using a MysqlConnection.
Limit
Set the LIMIT clause.
$limitis a number indicating the query limit.
$query->limit($limit);
Order By
Set the ORDER BY fields.
$fieldsis an array or string representing the fields to order by.$overwriteis a boolean indicating whether to overwrite existing fields, and will default to false.
$query->orderBy($fields, $overwrite);
Using
Set the USING tables.
$tableis an array or string representing the using table(s).$overwriteis a boolean indicating whether to overwrite existing using tables, and will default to false.
$query->using($table, $overwrite);
This method is only supported for queries using a PostgresConnection.
Where
Set the WHERE conditions.
$conditionsis an array or string representing the where conditions.$overwriteis a boolean indicating whether to overwrite existing conditions, and will default to false.
$query->where($conditions, $overwrite);
Array conditions can contain:
- Literal values with numeric keys.
- Key/value pairs where the key is the field (and comparison operator) and the value(s) will be escaped.
- Array values containing a group of conditions. These will be joined using the AND operator unless the array key is "OR" or "NOT".
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Insert
The \Fyre\DB\Queries\InsertQuery class extends the Query class, while providing additional methods for executing INSERT queries.
$connection ->insert() ->into($table) ->values($values) ->execute();
Epilog
Set the epilog.
$epilogis a string representing the epilog for the query.
$query->epilog($epilog);
Get Epilog
Get the epilog.
$epilog = $query->getEpilog();
Get Into
Get the INTO table.
$table = $query->getInto();
Get Values
Get the REPLACE data.
$values = $query->getValues();
Into
Set the INTO table.
$tableis a string representing the table.$overwriteis a boolean indicating whether to overwrite existing tables, and will default to false.
$query->into($table, $overwrite);
Values
$valuesis a 2-dimensional array of values to insert.$overwriteis a boolean indicating whether to overwrite existing data, and will default to false.
$query->values($values, $overwrite);
Array keys will be used for the column names, and the values will be escaped automatically.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Insert From
The \Fyre\DB\Queries\InsertFromQuery class extends the Query class, while providing additional methods for executing INSERT queries from SELECT queries.
$connection ->insertFrom($from, $columns) ->into($table) ->execute();
Epilog
Set the epilog.
$epilogis a string representing the epilog for the query.
$query->epilog($epilog);
Get Epilog
Get the epilog.
$epilog = $query->getEpilog();
Get Into
Get the INTO table.
$table = $query->getInto();
Into
Set the INTO table.
$tableis a string representing the table.$overwriteis a boolean indicating whether to overwrite existing tables, and will default to false.
$query->into($table, $overwrite);
Replace
The \Fyre\DB\Queries\ReplaceQuery class extends the Query class, while providing additional methods for executing REPLACE queries.
$connection ->replace() ->into($table) ->values($values) ->execute();
Epilog
Set the epilog.
$epilogis a string representing the epilog for the query.
$query->epilog($epilog);
Get Epilog
Get the epilog.
$epilog = $query->getEpilog();
Get Into
Get the INTO table.
$table = $query->getInto();
Get Values
Get the REPLACE data.
$values = $query->getValues();
Into
Set the INTO table.
$tableis a string representing the table.$overwriteis a boolean indicating whether to overwrite existing tables, and will default to false.
$query->into($table, $overwrite);
Values
$valuesis a 2-dimensional array of values to insert.$overwriteis a boolean indicating whether to overwrite existing data, and will default to false.
$query->values($values, $overwrite);
Array keys will be used for the column names, and the values will be escaped automatically.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Select
The \Fyre\DB\Queries\SelectQuery class extends the Query class, while providing additional methods for executing SELECT queries.
$results = $connection ->select($fields) ->from($table) ->where($conditions) ->execute();
Distinct
Set the DISTINCT clause.
$distinctis a boolean indicating whether to set the query as DISTINCT, and will default to true.
$query->distinct($distinct);
Epilog
Set the epilog.
$epilogis a string representing the epilog for the query.
$query->epilog($epilog);
Except
Add an EXCEPT query.
$unionis a Closure, SelectQuery, QueryLiteral or string representing the query.$overwriteis a boolean indicating whether to overwrite existing unions, and will default to false.
$query->except($union, $overwrite);
From
Set the FROM table(s).
$tableis an array or string representing the table(s).$overwriteis a boolean indicating whether to overwrite existing tables, and will default to false.
$query->from($table, $overwrite);
Non-numeric array keys will be used as table aliases.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection.
Get Distinct
Get the DISTINCT clause.
$distinct = $query->getDistinct();
Get Epilog
Get the epilog.
$epilog = $query->getEpilog();
Get Group By
Get the GROUP BY fields.
$groupBy = $query->getGroupBy();
Get From
Get the FROM table(s).
$table = $query->getFrom();
Get Having
Get the HAVING conditions.
$having = $query->getHaving();
Get Join
Get the JOIN tables.
$joins = $query->getJoin();
Get Limit
Get the LIMIT clause.
$limit = $query->getLimit();
Get Offset
Get the OFFSET clause.
$offset = $query->getOffset();
Get Order By
Get the ORDER BY fields.
$orderBy = $query->getOrderBy();
Get Select
Get the SELECT fields.
$fields = $query->getSelect();
Get Union
Get the UNION queries.
$unions = $query->getUnion();
Get Where
Get the WHERE conditions.
$conditions = $query->getWhere();
Get With
Get the WITH queries.
$with = $query->getWith();
Group By
Set the GROUP BY fields.
$fieldsis an array or string representing the fields to group by.$overwriteis a boolean indicating whether to overwrite existing fields, and will default to false.
$query->groupBy($fields, $overwrite);
Having
Set the HAVING conditions.
$conditionsis an array or string representing the having conditions.$overwriteis a boolean indicating whether to overwrite existing conditions, and will default to false.
$query->having($conditions, $overwrite);
Array conditions can contain:
- Literal values with numeric keys.
- Key/value pairs where the key is the field (and comparison operator) and the value(s) will be escaped automatically.
- Array values containing a group of conditions. These will be joined using the AND operator unless the array key is "OR" or "NOT".
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Intersect
Add an INTERSECT query.
$unionis a Closure, SelectQuery, QueryLiteral or string representing the query.$overwriteis a boolean indicating whether to overwrite existing unions, and will default to false.
$query->intersect($union, $overwrite);
Join
Set the JOIN tables.
$joinsis a 2-dimensional array of joins.$overwriteis a boolean indicating whether to overwrite existing joins, and will default to false.
$query->join($joins, $overwrite);
Each join array can contain a table, alias, type and an array of conditions. If the type is not specified it will default to INNER.
Limit
Set the LIMIT and OFFSET clauses.
$limitis a number indicating the query limit.$offsetis a number indicating the query offset.
$query->limit($limit, $offset);
Offset
Set the OFFSET clause.
$offsetis a number indicating the query offset.
$query->offset($offset);
Order By
Set the ORDER BY fields.
$fieldsis an array or string representing the fields to order by.$overwriteis a boolean indicating whether to overwrite existing fields, and will default to false.
$query->orderBy($fields, $overwrite);
Select
Set the SELECT fields.
$fieldsis an array or string representing the fields to select, and will default to "*".$overwriteis a boolean indicating whether to overwrite existing fields, and will default to false.
$query->select($fields, $overwrite);
Non-numeric array keys will be used as field aliases.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Union
Add a UNION DISTINCT query.
$unionis a Closure, SelectQuery, QueryLiteral or string representing the query.$overwriteis a boolean indicating whether to overwrite existing unions, and will default to false.
$query->union($union, $overwrite);
Union All
Add a UNION ALL query.
$unionis a Closure, SelectQuery, QueryLiteral or string representing the query.$overwriteis a boolean indicating whether to overwrite existing unions, and will default to false.
$query->unionAll($union, $overwrite);
Where
Set the WHERE conditions.
$conditionsis an array or string representing the where conditions.$overwriteis a boolean indicating whether to overwrite existing conditions, and will default to false.
$query->where($conditions, $overwrite);
Array conditions can contain:
- Literal values with numeric keys.
- Key/value pairs where the key is the field (and comparison operator) and the value(s) will be escaped.
- Array values containing a group of conditions. These will be joined using the AND operator unless the array key is "OR" or "NOT".
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
With
Set the WITH clause.
$withis an array of common table expressions.$overwriteis a boolean indicating whether to overwrite existing expressions, and will default to false.
$query->with($with, $overwrite);
Array keys will be used as table aliases.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection.
With Recursive
Set the WITH RECURSIVE clause.
$withis an array of common table expressions.$overwriteis a boolean indicating whether to overwrite existing expressions, and will default to false.
$query->withRecursive($with, $overwrite);
Array keys will be used as table aliases.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection.
Update
The \Fyre\DB\Queries\UpdateQuery class extends the Query class, while providing additional methods for executing UPDATE queries.
$connection ->update($table) ->set($data) ->where($conditions) ->execute();
Multiple tables is only supported for queries using a MysqlConnection.
Epilog
Set the epilog.
$epilogis a string representing the epilog for the query.
$query->epilog($epilog);
From
Set the FROM tables.
$tableis an array or string representing the from table(s).$overwriteis a boolean indicating whether to overwrite existing from tables, and will default to false.
$query->from($table, $overwrite);
This method is only supported for queries using a PostgresConnection or SqliteConnection.
Get Data
Get the UPDATE data.
$data = $query->getData();
Get Epilog
Get the epilog.
$epilog = $query->getEpilog();
Get From
Get the FROM table(s).
$table = $query->getFrom();
Get Join
Get the JOIN tables.
$joins = $query->getJoin();
Get Where
Get the WHERE conditions.
$conditions = $query->getWhere();
Join
Set the JOIN tables.
$joinsis a 2-dimensional array of joins.$overwriteis a boolean indicating whether to overwrite existing joins, and will default to false.
$query->join($joins, $overwrite);
Each join array can contain a table, alias, type and an array of conditions. If the type is not specified it will default to INNER.
This method is only supported for queries using a MysqlConnection.
Set
$datais an array of values to update.$overwriteis a boolean indicating whether to overwrite existing data, and will default to false.
$query->set($data, $overwrite);
Array keys will be used for the column names, and the values will be escaped automatically.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Where
Set the WHERE conditions.
$conditionsis an array or string representing the where conditions.$overwriteis a boolean indicating whether to overwrite existing conditions, and will default to false.
$query->where($conditions, $overwrite);
Array conditions can contain:
- Literal values with numeric keys.
- Key/value pairs where the key is the field (and comparison operator) and the value(s) will be escaped.
- Array values containing a group of conditions. These will be joined using the AND operator unless the array key is "OR" or "NOT".
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Update Batch
The \Fyre\DB\Queries\UpdateBatchQuery class extends the Query class, while providing additional methods for executing batch UPDATE queries.
$connection ->updateBatch($table) ->set($data, $keys) ->execute();
Epilog
Set the epilog.
$epilogis a string representing the epilog for the query.
$query->epilog($epilog);
Get Data
Get the UPDATE data.
$data = $query->getData();
Get Epilog
Get the epilog.
$epilog = $query->getEpilog();
Set
$datais a 2-dimensional array of values to update.$keysis a string or array containing the keys to use for updating.$overwriteis a boolean indicating whether to overwrite existing data, and will default to false.
$query->set($data, $keys, $overwrite);
Array keys will be used for the column names, and the values will be escaped automatically.
If a SelectQuery or QueryLiteral is supplied as an array value they will be converted to a string and not escaped.
A Closure can also be supplied as an array value, where the first argument will be the Connection and the second argument will be the ValueBinder.
Results
SELECT queries will return a new ResultSet containing the results of the query.
The ResultSet is an implementation of an Iterator and can be used in a foreach loop.
foreach ($result AS $row) { }
All
Get the results as an array.
$array = $result->all();
Clear Buffer
Clear the results from the buffer.
$indexis a number representing the index of the result to clear.
$result->clearBuffer($index);
Alternatively, if the $index argument is omitted, the entire buffer will be cleared.
$result->clearBuffer();
Column Count
Get the column count.
$columnCount = $result->columnCount();
Columns
Get the result columns.
$columns = $result->columns();
Count
Get the result count.
$count = $result->count();
Fetch
Get a result by index.
$indexis a number indicating the row index.
$row = $result->fetch($index);
First
Get the first result.
$first = $result->first();
Free
Free the result from memory.
$result->free();
Get Type
Get the Type for a column.
$nameis a string representing the column name.
$parser = $result->getType($name);
Last
Get the last result.
$last = $result->last();