tsukasa / query_builder
0.1
2019-01-06 11:24 UTC
Requires
- doctrine/dbal: ^2.5
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-29 05:40:34 UTC
README
- Subject: SQL Query builder
- Syntax: Django-like lookups
- Documentation: Russian
- PHP version: 5.6+
- Composer:
composer require tsukasa/query_builder
- Packagist: tsukasa/QueryBuilder
- License:
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