PHPackages                             sukhrobnurali/querylite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. sukhrobnurali/querylite

ActiveLibrary[Database &amp; ORM](/categories/database)

sukhrobnurali/querylite
=======================

QueryLite - A Lightweight SQL Query Builder

v1.0.0(1y ago)428MITPHPPHP &gt;=8.1

Since Jun 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sukhrobnurali/querylite)[ Packagist](https://packagist.org/packages/sukhrobnurali/querylite)[ RSS](/packages/sukhrobnurali-querylite/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

🚀 QueryLite - Lightweight SQL Query Builder
===========================================

[](#-querylite---lightweight-sql-query-builder)

QueryLite is a **fast**, **lightweight**, and **easy-to-use** database query builder that simplifies SQL interactions using native **PDO**. It provides an intuitive **model-based API** while ensuring raw SQL performance.

---

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require sukhrobnurali/querylite
```

📌 Example Usage
---------------

[](#-example-usage)

### **1️⃣ Define a Model**

[](#1️⃣-define-a-model)

Extend `QueryLite` to define your own database model.

```
class UserModel extends QueryLite
{
    const TABLE = 'users';

    protected function create($name, $email) {
        $this->insert(['name' => $name, 'email' => $email]);
    }
}
```

### **2️⃣ Establish a Database Connection**

[](#2️⃣-establish-a-database-connection)

Before using QueryLite, set up a **PDO connection**:

```
$connection = new PDO(
    "mysql:host=127.0.0.1;dbname=your_database;charset=utf8mb4",
    "your_user",
    "your_password",
    [
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    ]
);
```

### **3️⃣ Query the Database**

[](#3️⃣-query-the-database)

🔹 **Select Data**

```
$userModel = new UserModel($connection);

$users = $userModel->select(['id', 'name'])
    ->where('age', '>', 18)
    ->orderBy('name ASC')
    ->limit(100)
    ->getAllRows();
```

🔹 **Insert Data**

```
$userModel->insert([
    'name' => 'John Doe',
    'email' => 'john@example.com'
]);
```

🔹 **Update Data**

```
$userModel->update(['email' => 'new@example.com'])
    ->whereEqual('id', 1);
```

🔹 **Delete Data**

```
$userModel->delete()
    ->whereEqual('id', 5);
```

---

🛠 QueryLite API Methods
-----------------------

[](#-querylite-api-methods)

MethodDescriptionExample`select($columns)`Select specific columns from a table`$userModel->select(['id', 'name']);``where($column, $operator, $value)`Add a WHERE condition`$userModel->where('status', '=', 'active');``orderBy($column, $direction)`Add sorting to queries`$userModel->orderBy('id', 'DESC');``limit($count)`Limit query results`$userModel->limit(50);``insert($data)`Insert new records`$userModel->insert(['name' => 'Jane']);``update($data)`Update records`$userModel->update(['email' => 'test@example.com']);``delete()`Delete records`$userModel->delete()->whereEqual('id', 1);``getAllRows()`Fetch all results`$userModel->getAllRows();`🛠 Running Tests
---------------

[](#-running-tests)

To ensure QueryLite functions correctly, run:

```
# Run all tests using Composer
composer test
```

---

🌟 Features
----------

[](#-features)

✅ **Minimal &amp; Fast** – Built on native PDO for raw SQL execution.
✅ **Chainable Query Methods** – Clean and readable query building.
✅ **Supports MySQL &amp; SQLite** – Works seamlessly with popular databases.
✅ **No Dependencies** – Fully self-contained, no external libraries needed.
✅ **Customizable &amp; Extendable** – Easily define models and extend functionality.

---

👨‍💻 Contribution &amp; Support
------------------------------

[](#‍-contribution--support)

Feel free to **contribute** or provide feedback to improve QueryLite. If you encounter any issues, submit a **bug report** or suggest **new features**.

📩 **Contact:** Open an issue on GitHub or email ****

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

556d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/59318027?v=4)[Sukhrob Nurali](/maintainers/sukhrobnurali)[@sukhrobnurali](https://github.com/sukhrobnurali)

---

Top Contributors

[![sukhrobnurali](https://avatars.githubusercontent.com/u/59318027?v=4)](https://github.com/sukhrobnurali "sukhrobnurali (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sukhrobnurali-querylite/health.svg)

```
[![Health](https://phpackages.com/badges/sukhrobnurali-querylite/health.svg)](https://phpackages.com/packages/sukhrobnurali-querylite)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.8k117.8M121](/packages/jdorn-sql-formatter)[backup-manager/backup-manager

A framework agnostic database backup manager with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more with drivers for popular frameworks.

1.7k1.6M11](/packages/backup-manager-backup-manager)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M88](/packages/propel-propel1)[insolita/yii2-migration-generator

Set of gii tools for generating files for migration by schema of table , phpdoc or table data

108508.0k5](/packages/insolita-yii2-migration-generator)[xpdo/xpdo

A PDO-based Object/Relational Bridge Library

7088.4k4](/packages/xpdo-xpdo)[voku/session2db

A PHP library acting as a wrapper for PHP's default session handling functions which stores data in a MySQL database, providing both better performance and better security and protection against session fixation and session hijacking.

2920.0k](/packages/voku-session2db)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
