Getting started

Installation

Using composer

Run in a console

composer require finesse/query-scribe

Usage

First make a grammar object. Grammar compiles queries to SQL with bindings.

use Finesse\QueryScribe\Grammars\CommonGrammar;

$grammar = new CommonGrammar();

Available grammars:

Then make an empty query:

use Finesse\QueryScribe\Query;

$query = new Query;

Build a query:

$query
    ->addSelect(['name', 'id'])
    ->from('users')
    ->limit(10);

Compile the query:

$compiled = $grammar->compile($query);

// You can specify the query type explicitly:
$compiled = $grammar->compileSelect($query);

$sql = $compiled->getSQL();
$parameters = $compiled->getBindings();

One grammar can be used many times for different queries.