Getting started


Using composer

Run in a console

composer require finesse/query-scribe


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

use Finesse\QueryScribe\Grammars\CommonGrammar;

$grammar = new CommonGrammar();

Available grammars:

  • Finesse\QueryScribe\Grammars\MySQLGrammar — MySQL
  • Finesse\QueryScribe\Grammars\SQLiteGrammar — SQLite
  • Finesse\QueryScribe\Grammars\CommonGrammar — everything else

Then make an empty query:

use Finesse\QueryScribe\Query;

$query = new Query;

Build a query:

    ->addSelect(['name', 'id'])

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.