PHPackages                             nogagermainio/noga-se - 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. nogagermainio/noga-se

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

nogagermainio/noga-se
=====================

Fast, fluent and immutable SQL Query Builder for PHP 8.1+ with secure parameter binding and advanced query features.

v0.1.0(today)11↑2900%MITPHPPHP &gt;=8.1CI passing

Since Jul 1Pushed todayCompare

[ Source](https://github.com/nogagermainio/Noga_SE)[ Packagist](https://packagist.org/packages/nogagermainio/noga-se)[ Docs](https://github.com/nogagermainio/Noga_SE)[ RSS](/packages/nogagermainio-noga-se/feed)WikiDiscussions main Synced today

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

🗄️ Noga\_SE - Modern SQL QueryBuilder
=====================================

[](#️-noga_se---modern-sql-querybuilder)

[![License](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/f8d3a5ff01aa798380a3924c1dd664ff2690793107550a190233923694d1d4b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312b2d677265656e2e737667)](https://php.net)[![Composer](https://camo.githubusercontent.com/832f8b44996490baec5db2927f503eea8c387a557d6c9930839873205383505f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6d706f7365722d52656164792d627269676874677265656e2e737667)](https://packagist.org)[![Latest Version](https://camo.githubusercontent.com/8d88a1f5646554f95f6a3eaa8bc946789ff89be5fbcee7a377291c2cf60905ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f67616765726d61696e696f2f6e6f67612d7365)](https://packagist.org/packages/nogagermainio/noga-se)

[![Status](https://camo.githubusercontent.com/f9abd5e3e4958db47256814d395b7923defa3d1fb609e0ce304c50406ce2cd69/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d737563636573733f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/f9abd5e3e4958db47256814d395b7923defa3d1fb609e0ce304c50406ce2cd69/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d737563636573733f7374796c653d666f722d7468652d6261646765)[![Type](https://camo.githubusercontent.com/9e40acab05ffcf4fafd967faecb9d8e3f0fee1ed11cf38a3fd08f040470a5ea2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747970652d71756572796275696c6465722d696d706f7274616e743f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/9e40acab05ffcf4fafd967faecb9d8e3f0fee1ed11cf38a3fd08f040470a5ea2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747970652d71756572796275696c6465722d696d706f7274616e743f7374796c653d666f722d7468652d6261646765)[![Architecture](https://camo.githubusercontent.com/42af79c9a902328d0e5024bfd8bdd168b2dfe8750fee9170473bb23a58cb60b0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6172636869746563747572652d696d6d757461626c652d626c61636b3f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/42af79c9a902328d0e5024bfd8bdd168b2dfe8750fee9170473bb23a58cb60b0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6172636869746563747572652d696d6d757461626c652d626c61636b3f7374796c653d666f722d7468652d6261646765)

[![MySQL](https://camo.githubusercontent.com/900075360c3d47874a031709b94b6788a7b7f341a57012d3f5a35cf6c5a2b816/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d7953514c2d737570706f727465642d3434373941313f7374796c653d666f722d7468652d6261646765266c6f676f3d6d7973716c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/900075360c3d47874a031709b94b6788a7b7f341a57012d3f5a35cf6c5a2b816/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d7953514c2d737570706f727465642d3434373941313f7374796c653d666f722d7468652d6261646765266c6f676f3d6d7973716c266c6f676f436f6c6f723d7768697465)[![PostgreSQL](https://camo.githubusercontent.com/48554260aae3b1e646359d7aac0362a80045788e6b3be88f2b83d7a23a4ff39a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f737467726553514c2d737570706f727465642d3333363739313f7374796c653d666f722d7468652d6261646765266c6f676f3d706f737467726573716c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/48554260aae3b1e646359d7aac0362a80045788e6b3be88f2b83d7a23a4ff39a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f737467726553514c2d737570706f727465642d3333363739313f7374796c653d666f722d7468652d6261646765266c6f676f3d706f737467726573716c266c6f676f436f6c6f723d7768697465)[![SQLite](https://camo.githubusercontent.com/4f600a2e81d6756a747b1347d6d6b6058ec69edcba5145358412d431ebff0908/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53514c6974652d737570706f727465642d3030334235373f7374796c653d666f722d7468652d6261646765266c6f676f3d73716c697465266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/4f600a2e81d6756a747b1347d6d6b6058ec69edcba5145358412d431ebff0908/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53514c6974652d737570706f727465642d3030334235373f7374796c653d666f722d7468652d6261646765266c6f676f3d73716c697465266c6f676f436f6c6f723d7768697465)

[![Security](https://camo.githubusercontent.com/dcfb6119435ba829905253468bd7aa066daa4ad0feffd0f117a5404bdd2de3f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73656375726974792d73716c5f696e6a656374696f6e5f736166652d677265656e3f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/dcfb6119435ba829905253468bd7aa066daa4ad0feffd0f117a5404bdd2de3f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73656375726974792d73716c5f696e6a656374696f6e5f736166652d677265656e3f7374796c653d666f722d7468652d6261646765)[![Performance](https://camo.githubusercontent.com/b24687071bc972942ab0cead396a01be5a7976f9cadc3badc433715606994158/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706572666f726d616e63652d6f7074696d697a65642d6f72616e67653f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/b24687071bc972942ab0cead396a01be5a7976f9cadc3badc433715606994158/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706572666f726d616e63652d6f7074696d697a65642d6f72616e67653f7374796c653d666f722d7468652d6261646765)[![Style](https://camo.githubusercontent.com/dcaeefa35b9ceb16019f1d78aa76aa0764b1e13b76c8d2478cdd912d7afda8c9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6170692d666c75656e742532306275696c6465722d626c756576696f6c65743f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/dcaeefa35b9ceb16019f1d78aa76aa0764b1e13b76c8d2478cdd912d7afda8c9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6170692d666c75656e742532306275696c6465722d626c756576696f6c65743f7374796c653d666f722d7468652d6261646765)

[![Stars](https://camo.githubusercontent.com/e95a610d6d0b76a01e28cfa97f786c7ca4eea05c84de029329ac35a12158e4a8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e6f67616765726d61696e696f2f4e6f67615f53453f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/e95a610d6d0b76a01e28cfa97f786c7ca4eea05c84de029329ac35a12158e4a8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e6f67616765726d61696e696f2f4e6f67615f53453f7374796c653d666f722d7468652d6261646765)[![Forks](https://camo.githubusercontent.com/5e28425833662cf20dba8f573660ec9a4a6515c937b23d7fb82c4afdf7269a95/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6e6f67616765726d61696e696f2f4e6f67615f53453f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/5e28425833662cf20dba8f573660ec9a4a6515c937b23d7fb82c4afdf7269a95/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6e6f67616765726d61696e696f2f4e6f67615f53453f7374796c653d666f722d7468652d6261646765)[![Issues](https://camo.githubusercontent.com/43540aee161159ba5877de71776f78eb08253099010181628ee2d75646587659/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6e6f67616765726d61696e696f2f4e6f67615f53453f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/43540aee161159ba5877de71776f78eb08253099010181628ee2d75646587659/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6e6f67616765726d61696e696f2f4e6f67615f53453f7374796c653d666f722d7468652d6261646765)

**Noga\_SE** is a modern, fluent, and immutable SQL QueryBuilder built in PHP 8.1+. It provides an elegant and secure API for building SELECT, INSERT, UPDATE, and DELETE queries with automatic parameter binding to prevent SQL injections.

---

✨ Key Features
--------------

[](#-key-features)

### 🔧 Complete CRUD Operations

[](#-complete-crud-operations)

- **SELECT** - Complex queries with joins, subqueries, aggregations, CTEs
- **INSERT** - Single and batch insertions with secure binding
- **UPDATE** - Safe updates with WHERE conditions
- **DELETE** - Protected deletions with conditions

### 🛡️ Advanced Security

[](#️-advanced-security)

- **Parameter Binding** - Automatic binding prevents SQL injections
- **BindHashing** - Cryptographically random parameter keys (`:prefix_hexrand_colname`)
- **Immutability** - Automatic cloning prevents mutations
- **Type Safety** - Strict type checking with exceptions

### ⚙️ Powerful Features

[](#️-powerful-features)

- **Complex WHERE Clauses** - AND, OR, LIKE, BETWEEN, IN, EXISTS, NOT IN
- **Joins** - INNER, LEFT, RIGHT, CROSS joins with multiple tables
- **Subqueries** - Nested queries via callables, Select instances, or strings
- **Aggregations** - GROUP BY, HAVING, COUNT, MAX, MIN, SUM, AVG
- **Unions** - UNION, UNION ALL for combining results
- **CTEs** - Common Table Expressions with recursive support
- **Sorting &amp; Pagination** - ORDER BY, GROUP BY, LIMIT, OFFSET
- **Query Caching** - Reuse compiled queries efficiently

### 🔗 Fluent API

[](#-fluent-api)

```
$query = Noga::table('users')
    ->select('id', 'name', 'email')
    ->where(['status' => 'active'])
    ->orderBy('created_at', 'DESC')
    ->limit(10);
```

### 🎨 Design Patterns

[](#-design-patterns)

- **Facade Pattern** - Unified static API
- **Builder Pattern** - Chainable query construction
- **Immutable Pattern** - Safe object cloning
- **Singleton Pattern** - Single instances for managers
- **Traits** - Reusable functionality (conditions, aggregations)

---

### Manual Installation

[](#manual-installation)

1. Clone the repository
2. Configure autoloading in `composer.json`:

```
{
  "autoload": {
    "psr-4": {
      "Noga\\": "src/"
    }
  }
}
```

---

🚀 Quick Start Guide
-------------------

[](#-quick-start-guide)

### CONFIGURATION

[](#configuration)

index.php

```
//autoload.php

use Noga\Core\Config;
use Noga\Noga;

// special config files read ngconfig.ng
(new Config(__DIR__."/Config/ngconfig.ng"))->loadEnv();

//Config QueryBuilder
Noga::config(
   basePath:__DIR__, // application basePath
   cachePath:__DIR__."/src/cache", // application cache path
   driver:'sqlite' // application default driver
);
```

### 1️⃣ SELECT - Reading Data

[](#1️⃣-select---reading-data)

#### Basic Query

[](#basic-query)

```
use Noga\Noga;

$users = Noga::table('users')
    ->select('id', 'name', 'email')
    ->get();
```

#### With Conditions

[](#with-conditions)

```
$activeUsers = Noga::table('users')
    ->select('*')
    ->where(['status' => 'active', 'age >=' => 18])
    ->get();
```

#### With Joins

[](#with-joins)

```
$userPosts = Noga::table('users')
    ->select('users.name', 'posts.title')
    ->innerJoin(Noga::joins('posts', 'p')
        ->on('users.id', '=', 'p.user_id'))
    ->get();
```

#### With Subqueries

[](#with-subqueries)

```
$topUsers = Noga::table('users')
    ->select('id', 'name')
    ->whereIn('id', fn($q) =>
        $q->table('orders')
            ->select('user_id')
            ->where(['status' => 'completed'])
    )
    ->get();
```

#### With Aggregations

[](#with-aggregations)

```
$stats = Noga::table('orders')
    ->select('user_id', 'COUNT(*) as total_orders')
    ->groupBy(['user_id'])
    ->having(['total_orders >' => 5])
    ->get();
```

#### With Sorting &amp; Pagination

[](#with-sorting--pagination)

```
$topUsers = Noga::table('users')
    ->select('*')
    ->orderBy('created_at', 'DESC')
    ->limit(10)
    ->offset(20)
    ->get();
```

### 2️⃣ INSERT - Creating Data

[](#2️⃣-insert---creating-data)

Executing mode :

```
->exec(); //interact with database
->getQuery(); //inspect Sql query string
->getValues(); //get all values
->viewState(); // show request
```

#### Single Insertion

[](#single-insertion)

```
use Noga\Noga;

$result = Noga::insert('users')
    ->columns('name', 'email', 'status')
    ->values('John Doe', 'john@example.com', 'active')
    ->exec(); //execute mode PDO
```

#### bulk Insertions

[](#bulk-insertions)

```
$result = Noga::insert('users')
    ->from(__DIR__."/../membres.json")
    ->take() // obligatory
    ->viewState();

 json format
    // [
// {"id":"48","identifiant":"659225887","noms":"Noga","prenoms":"Germainio"},
// {"id":"48","identifiant":"659225887","noms":"Ephore","prenoms":"Miasa"},
//  ....
    // ]
```

#### Debug Insertion

[](#debug-insertion)

```
$debug = Noga::insert('users')
    ->columns('name', 'email')
    ->values('Test', 'test@example.com')
    ->viewState();

// output
//   "sql": "INSERT INTO users( name,email )  VALUES(:in_c9f9f93a_name,:in_968abc56_email)",
//     "params": {
//         ":in_c9f9f93a_name": "Test",
//         ":in_968abc56_email": "test@example.com"
//     },
//     "driver": "mysql",
//     "table": "users",
//     "columns": [
//         "name",
//         "email"
//     ],
//     "values": [
//         "Test",
//         "test@example.com"
//     ],
//     "binding": [
//         ":in_c9f9f93a_name",
//         ":in_968abc56_email"
//     ]
```

### 3️⃣ UPDATE - Modifying Data

[](#3️⃣-update---modifying-data)

execution mode :

```
->exec(); //interact with database
->getQuery(); //inspect Sql query string
->getValues(); //get all values
->viewState(); // show request
```

#### Simple Update

[](#simple-update)

```
$result = Noga::update('users')
    ->set(['status' => 'active', 'updated_at' => 'NOW()'])
    ->where(['id' => 5])
    ->exec(); //PDO request
```

#### Update with Complex Conditions

[](#update-with-complex-conditions)

```
$result = Noga::update("users")
          ->set(['verified' => true])
          ->where([
        'email' => 'test@example.com',
        'status' => 'inactive'
            ])
          ->exec();
```

### 4️⃣ DELETE - Removing Data

[](#4️⃣-delete---removing-data)

execution mode :

```
->exec(); //interact with database
->getQuery(); //inspect Sql query string
->getParams(); //get all params binding
->viewState(); // show request
```

#### Simple Deletion

[](#simple-deletion)

```
$result = Noga::delete('users')
    ->where(['id' => 1])
    ->exec();
```

#### Safe Deletion with Limits

[](#safe-deletion-with-limits)

```
$result = Noga::delete('users')
    ->where(['status' => 'inactive', 'last_login ', 'updated_at')          // Column comparison
->isNull('deleted_at')                                  // IS NULL
->isNotnull('verified_at')                              // IS NOT NULL
->whereExists(fn($q) => ...)                            // EXISTS subquery
->whereNotExists(fn($q) => ...)                         // NOT EXISTS
```

#### Joins

[](#joins)

```
->innerJoin(Noga::j('posts', 'p')
    ->on('users.id', '=', 'p.user_id'))

->leftJoin(Noga::j('comments', 'c')
    ->on('posts.id', '=', 'c.post_id'))

->rightJoin(Noga::j('categories', 'cat')
    ->on('posts.category_id', '=', 'cat.id'))

->crossJoin(Noga::j('departments', 'd'))
```

#### Grouping &amp; Aggregation

[](#grouping--aggregation)

```
->groupBy(['status', 'created_at'])
->having(['count >' => 5])
```

#### Sorting &amp; Pagination

[](#sorting--pagination)

```
->orderBy('created_at', 'DESC')  // ASC or DESC
->limit(10)                       // Limit results
->offset(20)                      // Skip results
```

#### Unions

[](#unions)

```
//union simple
->union(Noga::u()->table('admins')->select('id', 'name'))
->unionAll(Noga::u()->table('moderators')->select('id', 'name'))

//union with table dynamique
->unionAll(Noga::u()->from(['admin','moderators'])->select('id','name'))

// union with a condition multiple
->unionAll(Noga::u()->add([
    Noga::table("users")
    ->select("id","noms")
    ->where(["id"=>12])
    ]))
```

#### CTEs (Common Table Expressions)

[](#ctes-common-table-expressions)

```
->with('recent_users',
    fn($q) => $q->table('users')
        ->where(['created_at >' => 'NOW()'])
)

->with('category_tree',
    fn($q) => $q->table('categories')
        ->select('id', 'name', 'parent_id')
        ->where(['parent_id' => null]),
    true  // Recursive
)
```

#### Execution Methods

[](#execution-methods)

```
->get()                    // All results as objects
->getOne()                 // Single row
->getStream()              // Generator for large datasets
->getQuery()                 // Compiled SQL string
->getParams()              // Bound parameters array
->viewState()               // Complete request info
```

---

🏗️ Project Architecture
-----------------------

[](#️-project-architecture)

```
src/
├── Noga.php                             # Main Facade
├── QueryBuilder/
│   ├── builder.php                     # Clause construction
│   ├── select/                         # SELECT implementation
│   └── crud/                           # INSERT, UPDATE, DELETE
├── Core/
│   ├── BindHashing.php                 # Secure parameter hashing
│   ├── CacheManager.php                # Query caching
│   ├── Sqlast.php                      # SQL parsing & AST
│   ├── NgManager.php                   # Configuration management
│   └── DateManager.php                 # Date formatting (FR/EN)
├── Db/
│   ├── DB.php                          # Database abstraction
│   ├── mysql.php                       # MySQL driver
│   ├── postgres.php                    # PostgreSQL driver
│   └── sqlite.php                      # SQLite driver
├── Traits/
│   ├── BuidlerAttr.php                 # Builder attributes
│   ├── aggregate.php                   # Aggregation functions
│   ├── condition.php                   # Condition building
│   └── dbTrait.php                     # Database connection
├── helpers/
│   └── helpers.php                     # Utility functions
├── CLI/
│   ├── kernel.php                      # Command dispatcher
│   └── commands/                       # Custom commands
├── cache/                              # Query cache storage
├── exceptions/                         # Custom exceptions
└── mapping/                            # Data mapping

```

---

🔒 Security in Depth
-------------------

[](#-security-in-depth)

### Parameter Binding (SQL Injection Prevention)

[](#parameter-binding-sql-injection-prevention)

```
// ❌ UNSAFE - Vulnerable to SQL injection
$query = "SELECT * FROM users WHERE id = $id";

// ✅ SAFE - Parameters are bound
$query = Noga::table('users')
    ->where(['id' => $id])  // Automatically bound
    ->get();
```

### BindHashing Mechanism

[](#bindhashing-mechanism)

```
Parameter Key Generation:
Input: ['id' => 5, 'status' => 'active']

↓ BindHashing::hash()

Output:
  :wh_a1b2c3d4_id => 5
  :wh_e5f6g7h8_status => "active"

Each key is:
- Prefixed (:wh_ for WHERE)
- Random hex (a1b2c3d4)
- Column name
- Cryptographically secure
- Impossible to predict or inject

```

### Immutability for Safety

[](#immutability-for-safety)

```
$base = Noga::table('users');
$active = $base->where(['status' => 'active']);
$admins = $base->where(['role' => 'admin']);

// $base, $active, $admins are 3 different objects
// No side effects or shared state
```

---

🧪 Testing
---------

[](#-testing)

### Run Tests

[](#run-tests)

```
# Unix/Linux/Mac
./noga test

# Windows
noga.bat test
```

### Test Files

[](#test-files)

- `test/NogaTest.php` - PHPUnit test suite
- `test/test.php` - Basic examples
- `test/users.php` - User table examples

### Test Configuration

[](#test-configuration)

```

            ./test

```

---

💡 Advanced Examples
-------------------

[](#-advanced-examples)

### Complex Multi-Level Query

[](#complex-multi-level-query)

```
$results = Noga::table('orders')
    ->select(
        'orders.id',
        'orders.total',
        'customers.name',
        'COUNT(items.id) as item_count'
    )
    ->innerJoin(Noga::joins('customers', 'c')
        ->on('orders.customer_id', '=', 'c.id'))
    ->innerJoin(Noga::joins('order_items', 'items')
        ->on('orders.id', '=', 'items.order_id'))
    ->where([
        'orders.status' => 'completed',
        'orders.created_at >=' => '2024-01-01'
    ])
    ->groupBy(['orders.id', 'customers.name'])
    ->having(['item_count >' => 3])
    ->orderBy('orders.total', 'DESC')
    ->limit(20)
    ->get();
```

### Recursive CTE

[](#recursive-cte)

```
$hierarchy = Noga::table('categories')
    ->with('category_tree',
        fn($q) => $q->table('categories')
            ->select('id', 'name', 'parent_id')
            ->where(['parent_id' => null]),
        true  // Recursive
    )
    ->select('*')
    ->get();

    //or
    $hierarchy = Noga::table('categories')
    ->with('category_tree',
        Noga::table('categories')
            ->select('id', 'name', 'parent_id')
            ->where(['parent_id' => null]),
        true  // Recursive
    )
    ->select('*')
    ->get();
```

### Query Caching

[](#query-caching)

```
// Register query
Noga::table('users')
    ->select('id', 'name')
    ->where(['status' => 'active'])
    ->add_query('get_active_users');

// Reuse from cache
$users = Noga::use_query('get_active_users')->get();

// Clear cache
Noga::removeCache('get_active_users');
Noga::removeAllCache();
```

### EXPLAIN Query Analysis

[](#explain-query-analysis)

```
$analysis = Noga::explain(
    Noga::table('users')
        ->select('*')
        ->where(['id' => 1]),
    'FORMAT=JSON'
);
```

---

🔧 Configuration
---------------

[](#-configuration)

### Database Configuration

[](#database-configuration)

Configure via `NgManager` or environment file:

```
// Initialize configuration
$config = NgManager::getInstance('path/to/ngconfig.ng');

// Access parameters
$host = ng('db_host');
$port = ng('db_port', 3306);
```

### Cache Configuration

[](#cache-configuration)

```
CacheManager::key("my_query")
    ->dir("queries")
    ->delay(3600)  // 1 hour
    ->data($result)
    ->put();
```

---

🎯 Use Cases
-----------

[](#-use-cases)

✅ **Modern Web Applications** - Build safe, fluent queries
✅ **API Development** - Complex data retrieval with filters
✅ **Data Analysis** - Aggregations, CTEs, subqueries
✅ **Reporting Systems** - Multi-table joins and summaries
✅ **Admin Dashboards** - Dynamic filtering and sorting
✅ **Microservices** - Database abstraction layer

---

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please follow these steps:

1. Fork the project
2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

### Development Setup

[](#development-setup)

```
# Clone repository
git clone https://github.com/nogagermainio/Noga_SE.git
cd Noga_SE

# Install dependencies
composer install

# Run tests
./noga test

# Check code
./noga lint
```

---

📄 License
---------

[](#-license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

```
MIT License

Copyright (c) 2026 nogagermainio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions above.

```

---

👨‍💻 Author
----------

[](#‍-author)

**nogagermainio**

- GitHub: [@nogagermainio](https://github.com/nogagermainio)
- Email: [your-email@example.com](mailto:contact@nogagermainio.dev)

---

🔗 Related Projects
------------------

[](#-related-projects)

- **Noga\_Http** - HTTP Framework companion
- **Noga\_CLI** - Command-line interface tools
- [PHP PDO Documentation](https://www.php.net/manual/en/book.pdo.php)

---

🆘 Support &amp; Issues
----------------------

[](#-support--issues)

Found a bug? Want a feature? Please [open an issue](https://github.com/nogagermainio/Noga_SE/issues) with:

- ✅ Clear problem description
- ✅ Minimal code reproduction
- ✅ Expected vs actual behavior
- ✅ PHP version and OS

### Common Issues

[](#common-issues)

**Q: How do I prevent SQL injection?**
A: All parameters are automatically bound via BindHashing. Never concatenate user input!

**Q: Can I cache queries?**
A: Yes! Use `->add_query('name')` and `Noga::use_query('name')`

**Q: Is it compatible with my database?**
A: Noga\_SE supports MySQL, PostgreSQL, SQLite, and is easily extended for others.

**Q: How do I contribute?**
A: Fork the repo, create a feature branch, and submit a pull request.

---

📊 Roadmap
---------

[](#-roadmap)

### ✅ Completed

[](#-completed)

- SELECT with advanced clauses
- INSERT with secure binding
- UPDATE with conditions
- DELETE with protection
- Joins (INNER, LEFT, RIGHT, CROSS)
- Subqueries &amp; nesting
- Unions &amp; intersections
- Recursive CTEs
- Immutability &amp; cloning
- Query caching

### 🔄 In Progress

[](#-in-progress)

- Enhanced error reporting
- Performance profiling
- Query optimization hints
- Additional database drivers

### 📋 Planned

[](#-planned)

- Trigger &amp; stored procedure support
- Database schema builders
- Migration system
- Query logging middleware
- Batch optimization
- Full-text search support

---

📈 Performance Tips
------------------

[](#-performance-tips)

1. **Use Pagination** - Limit large result sets

    ```
    ->limit(20)->offset($page * 20)
    ```
2. **Cache Frequently Used Queries** - Reuse compiled queries

    ```
    ->add_query('active_users')
    ```
3. **Use Indexes** - Create database indexes on WHERE columns

    ```
    CREATE INDEX idx_status ON users(status);
    ```
4. **Batch Operations** - Insert multiple rows at once

    ```
    ->values(...)->values(...)->values(...)
    ```
5. **Select Only Needed Columns** - Avoid SELECT \*

    ```
    ->select('id', 'name', 'email')  // Not SELECT *
    ```

---

📞 Community &amp; Discussions
-----------------------------

[](#-community--discussions)

- 💬 [GitHub Discussions](https://github.com/nogagermainio/Noga_SE/discussions)
- 🐛 [Issue Tracker](https://github.com/nogagermainio/Noga_SE/issues)
- 📚 [Wiki &amp; Documentation](https://github.com/nogagermainio/Noga_SE/wiki)

---

🌟 Show Your Support
-------------------

[](#-show-your-support)

If you find Noga\_SE helpful, please consider:

- ⭐ Star the repository
- 🍴 Fork and contribute
- 📢 Share with your network
- 💬 Leave feedback

---

**Made with ❤️ by nogagermainio**

Last updated: 2026-07-01
Version: 1.0.0

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance100

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/adf72edb63331f64008bc289edfa35d7909b5c165ef17b2ce871d09728f117a0?d=identicon)[nogagermainio](/maintainers/nogagermainio)

---

Top Contributors

[![Noga-ng](https://avatars.githubusercontent.com/u/198326931?v=4)](https://github.com/Noga-ng "Noga-ng (28 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nogagermainio-noga-se/health.svg)

```
[![Health](https://phpackages.com/badges/nogagermainio-noga-se/health.svg)](https://phpackages.com/packages/nogagermainio-noga-se)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

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

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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