Download the PHP package craftix/lite-eloquent without Composer
On this page you can find all versions of the php package craftix/lite-eloquent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download craftix/lite-eloquent
More information about craftix/lite-eloquent
Files in craftix/lite-eloquent
Package lite-eloquent
Short Description Lightweight, dependency-free Eloquent-style PDO Query Builder for PHP
License MIT
Informations about the package lite-eloquent
Lite Eloquent
Lite Eloquent is a lightweight, high-performance PHP database query builder and ORM-inspired library.
It provides an easy-to-use, fluent API for building SQL queries with support for joins,
where clauses, pagination, and bindingsβwithout the heavy dependencies.
β¨ Features
- π High-performance PHP database query builder
- π¦ Lightweight and dependency-free (only requires PDO)
- π Fluent, chainable API similar to Eloquent
- π Secure with proper parameter bindings (SQL injection protection)
- ποΈ Multi-dialect support (MySQL, Pgsql)
- π Pagination support (simple and length-aware)
- π Transaction support
- π Collection class with array-like operations
- π― Type-safe with PHP 8.2+ features
Supported Operations
- β
SELECTqueries with columns, joins, where clauses, ordering, limit - β
INSERTqueries (single and bulk) - β
UPDATEqueries with where clauses - β
DELETEqueries with where clauses - β
UPSERToperations (MySQL: ON DUPLICATE KEY UPDATE, Pgsql: ON CONFLICT) - β
INSERT OR IGNOREoperations - β
Complex
WHEREconditions (nested groups, IN, BETWEEN, NULL checks, LIKE, etc.) - β
JOINclauses (INNER, LEFT, RIGHT, FULL) - β Raw SQL expressions
- β Pagination (with total count or simple)
- β Database transactions
π¦ Installation
Install via Composer:
Requirements:
- PHP >= 8.2
- PDO extension
π Quick Start
Basic Setup
Using Singleton Pattern
π Usage Examples
SELECT Queries
Basic Select
WHERE Clauses
JOIN Clauses
Ordering and Limits
Pagination
INSERT Queries
UPSERT Queries
UPDATE Queries
DELETE Queries
Raw Expressions
Transactions
Working with Collections
All query results return a Collection instance with helpful methods:
Custom Object Conversion
Getting SQL Query
Database Dialects
The library automatically detects the database dialect, but you can also set it manually:
π― API Reference
QueryBuilder Methods
Query Execution
get()- Execute SELECT and return Collectionfirst(...$columns)- Get first record (returns single value if one column, array if multiple)pluck($column)- Get single column as arraytoSql()- Get SQL string without executingpaginate($page, $perPage, $pageName = 'page')- Length-aware paginationsimplePaginate($page, $perPage, $pageName = 'page')- Simple pagination
Query Building
table($table)- Set table nameselect(...$columns)- Select columnsdistinct()- Add DISTINCTwhere($column, $operator, $value, $and = true)- Add WHERE conditionorWhere($column, $operator, $value)- Add OR WHERE conditionwhereIn($column, $values, $and = true)- WHERE INwhereNotIn($column, $values, $and = true)- WHERE NOT INwhereBetween($column, $value1, $value2, $and = true)- WHERE BETWEENwhereNotBetween($column, $value1, $value2, $and = true)- WHERE NOT BETWEENwhereNull($column, $and = true)- WHERE IS NULLwhereNotNull($column, $and = true)- WHERE IS NOT NULLwhereLike($column, $value, $and = true)- WHERE LIKEwhereNotLike($column, $value, $and = true)- WHERE NOT LIKEjoin($table, $column1, $operator, $column2, $type = 'INNER')- Add JOINleftJoin($table, $column1, $operator, $column2)- LEFT JOINrightJoin($table, $column1, $operator, $column2)- RIGHT JOINfullJoin($table, $column1, $operator, $column2)- FULL JOINorderBy($column, $type = 'ASC')- ORDER BYorderByDesc($column)- ORDER BY DESCinRandomOrder($seed = '')- Random orderlimit($limit)- LIMIToffset($offset)- OFFSET
Write Operations
insert($columnsToValues, &$resultedSql = null)- INSERTinsertGetId($columnsToValues, $idColumn = 'id', &$resultedSql = null)- INSERT and get IDinsertOrIgnore($columnsToValues, $uniqueColumns = null, &$resultedSql = null)- INSERT OR IGNOREupsert($columnsToValues, $uniqueBy, $updateOnDuplicate = null, &$resultedSql = null)- UPSERTupdate($columnsToValues, &$resultedSql = null)- UPDATEdelete(&$resultedSql = null)- DELETE
Utilities
raw($value)- Create raw SQL expressiongetValues()- Get bound parameter valuesobjectConverter($callback)- Set result object convertersetDialect($dialect)- Set SQL dialect
DB Class Methods
table($table)- Create QueryBuilder instancesetDialect($dialect)- Set dialectgetPdo()- Get PDO instancebeginTransaction()- Start transactioncommit()- Commit transactionrollBack()- Rollback transactioninTransaction()- Check if in transactiontransaction($callback)- Execute in transactionlastInsertId()- Get last insert IDexec($query, $params = null)- Execute raw SQLraw($value)- Create raw expression
Collection Methods
See the Collection documentation section above for available methods.
π Security
This library uses prepared statements with parameter binding by default, protecting against SQL injection attacks. Always use the query builder methods instead of raw SQL when possible.
π Error Handling
The library throws QueryBuilderException for query-related errors:
π License
This project is licensed under the MIT License.
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π§ Support
For issues, questions, or contributions, please visit the GitHub repository.
π Changelog
[1.1.0] - 2025-12-02
- Improved unit tests
- Added documentation for class methods and properties
[1.0.0] - 2025-11-15
- Initial release with core query builder and collection methods
All versions of lite-eloquent with dependencies
ext-pdo Version *