PHPackages                             cleup/database - 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. cleup/database

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

cleup/database
==============

Fast and elegant library for working with a database

1.0.1(1y ago)014MITPHPPHP &gt;=8.1

Since Aug 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/cleup/database)[ Packagist](https://packagist.org/packages/cleup/database)[ RSS](/packages/cleup-database/feed)WikiDiscussions main Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Cleup - Database
================

[](#cleup---database)

#### Installation

[](#installation)

Install the `cleup/database` library using composer:

```
composer require cleup/database

```

#### Usage

[](#usage)

##### Configuration

[](#configuration)

```
use Cleup\Core\Database\Db;

Db::config([
    'type'     => 'mysql', // pgsql, sybase, oracle, mssql, sqlite
    'host'     => 'localhost',
    'database' => 'db_name',
    'username' => 'db_user',
    'password' => '',
    'port'     => 3306,
    'charset'  => 'utf8mb4',
    'prefix'   => '',
]);
```

##### Methods

[](#methods)

```
use Cleup\Core\Database\Db;

# Select
// select("table name", "colums", "where|order|limit")
Db::select("users", "name");           // Single
Db::select("users", ["id", "name"]);   // Using an array
Db::select("users", "*");              // All columns
Db::select("users", "name", [          // Where syntax
    "email" => "mail@example.com",     // WHERE email = "mail@example.com"
    "id[>]" => 1,                      // WHERE id > 1
    "id[=]" => 7,                     // WHERE id >= 7
    "id[!]" => 5,                      // WHERE id != 5
    "age[]" => [20, 97],             // WHERE id BETWEEN 20 AND 97
    "age[]" => [30, 50],             // WHERE id NOT BETWEEN 30 AND 50
    "name[~]" => "Jimmy",              // WHERE "name" LIKE '%Jimmy%'
    "name[!~]" => "Jimmy",             // WHERE "name" NOT LIKE '%Jimmy%'
    "OR" => [                          // WHERE id IN (1,5,7) OR email IN ('mail@example.com', 'user@example.com')
        "id" => [1, 5, 7],
        "email" => [
            "mail@example.com",
            "user@example.com"
        ]
    ],
    "AND" => [                         // WHERE id != 3 AND age = 22
        'id[!]' => 3,
        'age' => 22
    ],
    "ORDER" => "id",                   // ORDER BY FIELD(`id`, 12,15),`name`,`date` DESC
    "ORDER" => [
        "id" => [12, 15],
        "name",
        "date" => "DESC"
    ],
    "LIMIT" => 50,                     // LIMIT 50
    "LIMIT" => [10, 50]                // LIMIT 50 OFFSET 10
]);
Db::select("users", "name", [          // Raw
    "ORDER" => Db::raw('RAND()'),
    'LIMIT' => Db::raw('AVG()')
    'date' => Db::raw('NOW()')
]);

# Insert
Db::insert("articles", [
    "title" => "My life",
    "email" => "",
    "active" => 1
]);
$articleId = $database->id();

# Update
Db::update("articles", [
    "active" => 0,
    "views[+]" => 1,                    // Plus one to the current value
    "views[-]" => 1,                    // Subtract one to the current value
]);

# Delete
Db::delete("articles", ['id' => 3])
Db::delete("articles", [
    "AND" => [
        "type" => "books",
        "views[]" => 30
]);

# Get
$email = Db::get("users", "email", [     // $email = "mail@example.com"
    "id" => 1
]);

# Has
$isAccount = Db::has("users", [          // true | false
    "id"=> 2,
    'verified' => 'Y'
]);

# Rand
$data = Db::rand("users", "*", [
    'id[>]' => 50
]);

# Count
$count = $database->count("users", [     // 100
    "gender" => "female"
]);

# Query
// The query syntax automatically creates a table prefix and analyzes the data to prepare for execution
$data = Db::query("SELECT ,  FROM ")->fetchAll();
$data = Db::query("SELECT * FROM  WHERE  = :name AND  = :age", [ // Prepared statement
    ":name" => "Mister X",
    ":age" => 18
])->fetchAll();

# Quote
$name = Db::quote("Edward");
$string = "My name is " . $name; // $string = "My name is  \'Edward\'"

# Create Table
Db::create("users", [
    "id" => [
        "INT",
        "NOT NULL",
        "AUTO_INCREMENT",
        "PRIMARY KEY"
    ],
    "name" => [
        "VARCHAR(30)",
        "NOT NULL"
    ]
], [
	"ENGINE" => "MyISAM",
	"AUTO_INCREMENT" => 5
]);

# Drop table
Db::drop("users");

# Logging
Db::insert("users", ["name" => "Edward"]);
$users = Db::select("users", "name", ['id' => 21]);
$log = Db::log();
/*
$log = array(
    0 => "INSERT INTO "users" ("name") VALUES (\'Edward\')",
    1 => "SELECT "name" FROM "users" WHERE "id" = 21"
);
*/
```

Based on [Medoo](https://github.com/catfan/Medoo) Database Framework

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

682d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/156127069?v=4)[cleup](/maintainers/cleup)[@cleup](https://github.com/cleup)

---

Top Contributors

[![priveted](https://avatars.githubusercontent.com/u/18353516?v=4)](https://github.com/priveted "priveted (1 commits)")

---

Tags

databasemysqlsqlitepgsqlmssqldbphp-db

### Embed Badge

![Health badge](/badges/cleup-database/health.svg)

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.8k](/packages/doctrine-dbal)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4883.1M38](/packages/aura-sqlquery)[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

44243.2k4](/packages/aura-sqlschema)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41256.9k7](/packages/atlas-query)[cycle/database

DBAL, schema introspection, migration and pagination

71777.8k53](/packages/cycle-database)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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