PQL
PQL - PHP Query Language, Database Query Library
This library is a database abstraction layer which abstracts the query commands (Select, Delete, Update, etc.) out from the drivers (MySQL, Postgres, SQL Server, etc.). Queries are defined in an eloquent way allowing you to write almost all kinds of queries without having to rely on passing raw query data.
Installation
Installation is done via composer composer install arekxv/pql
Usage
The easiest way to start is to let PdoDatabase resolve the driver and the builder for you from
the DSN and give you a ready to use runner:
use ArekX\PQL\Drivers\Pdo\PdoDatabase;
$runner = PdoDatabase::resolve([
'dsn' => 'mysql:host=127.0.0.1;dbname=your_database',
'username' => 'username',
'password' => 'password',
]);
See Getting Started for a full walkthrough.
Guides
- Getting Started - From installation to your first query.
- Writing Queries - All query types and helper functions for building queries.
- Statements - Calling procedures, functions and using CASE statements.
- Result Builder - Processing results after they are returned from the database.
- Transactions - Running multiple queries in an atomic way.
- Middleware - Hooking into the driver for logging, profiling and more.
- Security and User Input - What is safe for user input and what is not.
- Extending PQL - Custom DSN schemes, drivers and query builders.
- Architecture - How the library is put together.
Drivers
Following systems are supported:
- MySQL - MySQL database via PDO
- PostgreSQL - PostgreSQL database via PDO
- SQLite - SQLite database via PDO
- SQL Server - Microsoft SQL Server database via PDO
Testing
After installing the dependencies run composer test
For coverage report run composer coverage or you can take a look at it here.