semperton/query

A small and standalone SQL query builder.

1.0.0 2022-06-01 08:38 UTC

This package is auto-updated.

Last update: 2024-12-08 14:47:47 UTC


README

Semperton

Semperton Query

A small and standalone SQL query builder.

Installation

Just use Composer:

composer require semperton/query

Query requires PHP 7.2+

Intro

This is a SQL query builder only. All Instances of ExpressionInterface provide a compile method which takes a parameter array by reference and returns a parameter substituted SQL string that can be used with PDO for example.

$queryFactory = new QueryFactory();
$userSelect = $factory->select('user')->limit(5);

$sql = $userSelect->compile($params); // $params is passed by reference

$pdo = new PDO('dsn');
$stm = $pdo->prepare($sql);
$stm->execute($params);
$users = $stm->fetchAll();

// ...

Usage

Use your editor's autocomplete features for now ;)