Overview

DSQL is a dynamic SQL query builder. You can write multi-vendor queries in PHP profiting from better security, clean syntax and most importantly – sub-query support. With DSQL you stay in control of when queries are executed and what data is transmitted. DSQL is easily composable – build one query and use it as a part of other query.

Goals of DSQL

  • simple and concise syntax

  • consistently scalable (e.g. 5 levels of sub-queries, 10 with joins and 15 parameters? no problem)

  • “One Query” paradigm

  • support for PDO vendors as well as NoSQL databases (with query language similar to SQL)

  • small code footprint (over 50% less than competing frameworks)

  • free, licensed under MIT

  • no dependencies

  • follows design paradigms:

DSQL by example

The simplest way to explain DSQL is by example:

$query = $connection->dsql();
$query->table('employees')
    ->where('birth_date', '1961-05-02')
    ->field('count(*)');
echo 'Employees born on May 2, 1961: ' . $query->getOne();

The above code will execute the following query:

select count(*) from `salary` where `birth_date` = :a
    :a = "1961-05-02"

DSQL can also execute queries with multiple sub-queries, joins, expressions grouping, ordering, unions as well as queries on result-set.

  • See Quickstart if you would like to start learning DSQL.

DSQL is Part of Agile Toolkit

DSQL is a stand-alone and lightweight library with no dependencies and can be used in any PHP project, big or small.

Agile Toolkit Stack

DSQL is also a part of Agile Toolkit framework and works best with Agile Models. Your project may benefit from a higher-level data abstraction layer, so be sure to look at the rest of the suite.