2.4.1. Getting Started Installation

This package is installable and autoloadable via Composer as atlas/query. Add the following lines to your composer.json file, then call composer update.

    "require": {
        "atlas/query": "~1.0"
} Instantiation

Given an existing PDO instance, you can create a query using its static new() method:

use Atlas\Query\Select;
use Atlas\Query\Insert;
use Atlas\Query\Update;
use Atlas\Query\Delete;

$pdo = new PDO('sqlite::memory:');

$select = Select::new($pdo);
$insert = Insert::new($pdo);
$udpate = Update::new($pdo);
$delete = Delete::new($pdo);

(This also works with an existing Atlas.Pdo Connection instance.)

Alternatively, instantiate a QueryFactory ...

$queryFactory = new \Atlas\Query\QueryFactory();

...and then use the factory to create query objects for an Atlas.Pdo Connection.

$connection = \Atlas\Pdo\Connection::new('sqlite::memory:');

$select = $queryFactory->newSelect($connection);
$insert = $queryFactory->newInsert($connection);
$update = $queryFactory->newUpdate($connection);
$delete = $queryFactory->newDelete($connection);