PHPackages                             lcloss/db - 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. lcloss/db

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

lcloss/db
=========

Simple PHP package to manage database

048PHP

Since Oct 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lcloss/php-db)[ Packagist](https://packagist.org/packages/lcloss/db)[ RSS](/packages/lcloss-db/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

php-db
======

[](#php-db)

Simple PHP package to manage database

Install
-------

[](#install)

```
$ composer require lcloss/db
```

Requirements
------------

[](#requirements)

On root folder, create a .env file with these fields:

(Change accordanly your configuration)

```
[database]
driver = mysql
server = localhost
port   = 3306
dbname = testdb
user   = root
password =

```

Usage
-----

[](#usage)

### Using Database

[](#using-database)

You can use database directly, from static method `exec`:

```
    Database::exec( 'DROP DATABASE IF EXISTS activerecord;');
    Database::exec( 'CREATE DATABASE activerecord DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;');
    Database::exec( 'USE activerecord;');
    Database::exec( 'DROP TABLE IF EXISTS cliente;');
    $sql = name = "Some client";
    $client->address = "Some address street";

    $client->save();
```

### Select rows by `id`

[](#select-rows-by-id)

```
    $client = Client::find(1);
```

### Select all data

[](#select-all-data)

```
    $clients = Client::all();
```

### Navigating

[](#navigating)

```
    $cond = "name LIKE 'Some%'";
    $limit = 10;
    $offset = 20;
    $clients = Client::all($cond, $limit, $offset);
```

### Update rows

[](#update-rows)

```
    $client = Client::find(1);

    $client->name = "Changed to this name";
    $client->save();
```

### Delete rows

[](#delete-rows)

```
    $client = Client::find(1);
    $client->delete();
```

### Retrieving a list of rows

[](#retrieving-a-list-of-rows)

```
    for ($i = 1; $i < 11; $i++) {
        $client = new Client();
        $client->name = "Client {$i}";
        $client->address = "Street number {$i}";

        if ( $client->save(); ) {
            echo "Client {$i} saved!\n";
        } else {
            echo "There are a problem when saving client {$i}!\n";
        }
    }

    $clients = Client::all();

    foreach( $clients as $client )
    {
        echo $client->name . "\n";
    }
```

### Find first row

[](#find-first-row)

```
    $client = Client::findFirst("name = 'Client 4'");
    echo $client->name . "\n";
```

### Retrieving a list with conditions

[](#retrieving-a-list-with-conditions)

```
    $res = Client::all("address = 'Street 1'");
    foreach( $clients as $client )
    {
        echo $client->name . "\n";
    }
```

### Counting rows

[](#counting-rows)

```
    $rows = Client::count();
    echo "There are {$rows} clients on database.\n";
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

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.

### Community

Maintainers

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

---

Top Contributors

[![lcloss](https://avatars.githubusercontent.com/u/10761341?v=4)](https://github.com/lcloss "lcloss (21 commits)")

### Embed Badge

![Health badge](/badges/lcloss-db/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M542](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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