1.3.1. Getting Started

1.3.1.1. Installation

This package is installable and autoloadable via Composer as atlas/query.

$ composer require atlas/query ^2.0

1.3.1.2. Instantiation

Given an existing Connection instance from Atlas.Pdo, you can create a query object using the static new() method of the query type:

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

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

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

Alternatively, you can pass an existing PDO instance, which will get wrapped in a Connection for you:

use PDO;

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

You can also pass PDO construction arguments, in which case a new Connection will be created for you:

// PDO construction arguments
$insert = Insert::new('sqlite::memory');

Once you have a Query object, you will then be able to both build the query statement and and perform it through that Connection.