Download the PHP package abdulelahragih/querybuilder without Composer
On this page you can find all versions of the php package abdulelahragih/querybuilder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abdulelahragih/querybuilder
More information about abdulelahragih/querybuilder
Files in abdulelahragih/querybuilder
Package querybuilder
Short Description Fast, lightweight and simple SQL query builder that does not depend on any third-party library besides PDO to execute the queries in a safe way. The syntax is inspired by Laravel Query Builder.
License GPL-3.0-only
Informations about the package querybuilder
QueryBuilder
Fast, lightweight, and simple SQL query builder that does not depend on any third-party library besides PDO to execute the queries in a safe way. The syntax is inspired by Laravel Query Builder.
Features
- Automatic parameter binding via an internal bindings manager.
- Comprehensive WHERE builder: nested groups,
IN/NOT IN,LIKE/NOT LIKE,NULL/NOT NULL,BETWEEN/NOT BETWEEN. - Rich JOINs:
INNER,LEFT,RIGHT, andFULL(only on dialects that support it, e.g., PostgreSQL) with nested conditions andonhelpers. - Pagination:
paginate(length-aware) andsimplePaginate(no total count) with page name support. - Dialect-aware SQL generation with automatic detection (MySQL & Postgres for now).
- Inserts, updates, deletes with safety checks (no UPDATE/DELETE without WHERE).
- Upserts with dialect-specific behavior.
- Convenience helpers:
first,pluck,distinct,orderBy,limit,offset,rawexpressions,objectConverter. - Results as a fluent
Collectionand paginator objects.
Installation
Install via Composer:
Getting Started
Create a builder from a PDO instance. Dialect is auto-detected from PDO::ATTR_DRIVER_NAME (pgsql → Postgres; otherwise MySQL):
You can also use the thin DB wrapper (instance-based) or the DBSingleton for a static facade if you prefer:
Pagination
Length-aware pagination returns totals and page info:
Simple pagination is lighter weight:
Inserts and Upserts
-
Insert single or multiple rows:
-
Upsert with a unified API across dialects:
-
Do-nothing on conflict (Postgres):
- Insert and get the generated id (Postgres supports RETURNING, MySQL uses lastInsertId):
Updates and Deletes
Both operations require a WHERE clause for safety and return the affected rows count:
WHERE and JOIN Builders
- WHERE helpers:
where,orWhere,whereIn,whereNotIn,whereLike,whereNotLike,whereNull,whereNotNull,whereBetween,whereNotBetween, nested closures. - JOIN helpers:
join,leftJoin,rightJoin,fullJoin, plus nestedwhere/orWhereinside join closures andon/orOnfor column comparisons.
Examples (WHERE):
Examples (JOIN):
Object Conversion
Map rows to custom objects after fetching:
Transactions (Using the DB Wrapper)
Let the builder handle transactions:
Or manually:
Notes
- Update/Delete without a WHERE clause throws an exception by default.
insertGetIdexpects a single row payload.- Feature set varies slightly by dialect (e.g., Postgres
RETURNING,ON CONFLICT ... DO NOTHING).
Contribution
Contributions are welcome!
All versions of querybuilder with dependencies
ext-pdo Version *