tsukasa/query_builder

0.1 2019-01-06 11:24 UTC

This package is auto-updated.

Last update: 2024-10-29 05:40:34 UTC


README

Latest Stable Version Total Downloads Build Coverage Status Code Intelligence Status Scrutinizer Code Quality

  • Subject: SQL Query builder
  • Syntax: Django-like lookups
  • Documentation: Russian
  • PHP version: 5.6+
  • Composer: composer require tsukasa/query_builder
  • Packagist: tsukasa/QueryBuilder
  • License: License FOSSA Status

Basic usage

use Tsukasa\QueryBuilder\QueryBuilder

require('vendor/autoload.php'); // Composer autoloader

$connection = DriverManager::getConnection([
        'dbname' => 'mydb',
        'user' => 'user',
        'password' => 'secret',
        'host' => 'localhost',
        'driver' => 'pdo_mysql',
    ], 
    $config = new \Doctrine\DBAL\Configuration()
);


$qb = QueryBuilder::getInstance($connection);
$qb->setTypeSelect()
    ->setSelect('*')
    ->setFrom('comment')
    ->setWhere(['id__gte' => 1])
    ->setOrder(['created_at']);

$connection->fetchAll($qb->toSQL());
// SELECT * FROM comment WHERE id >= 1 ORDER BY created_at ASC