First, instantiate a QueryFactory with a database type:
use Aura\SqlQuery\QueryFactory;
$queryFactory = new QueryFactory('sqlite');
You can then use the factory to create query objects:
$select = $queryFactory->newSelect();
$insert = $queryFactory->newInsert();
$update = $queryFactory->newUpdate();
$delete = $queryFactory->newDelete();
Although you must specify a database type when instantiating a QueryFactory,
you can tell the factory to return "common" query objects instead of database-
specific ones. This will make only the common query methods available, which
helps with writing database-portable applications. To do so, pass the constant
QueryFactory::COMMON
as the second constructor parameter.
use Aura\SqlQuery\QueryFactory;
// return Common, not SQLite-specific, query objects
$queryFactory = new QueryFactory('sqlite', QueryFactory::COMMON);
N.b. You still need to pass a database type so that identifiers can be quoted appropriately.
All query objects implement the "Common" methods.
The query objects do not execute queries against a database. When you are done building the query, you will need to pass it to a database connection of your choice. In later examples, we will use PDO for the database connection, but any database library that uses named placeholders and bound values should work just as well (e.g. the Aura.Sql ExtendedPdo class).