PHPackages                             klintlili/easier-databases - 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. klintlili/easier-databases

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

klintlili/easier-databases
==========================

Base is a simple library that makes it easier to work with mysql databases in PHP

1.0.0(5y ago)23MITPHPPHP &gt;=5.6.0

Since Jul 30Pushed 5y agoCompare

[ Source](https://github.com/klintlili/easier-database)[ Packagist](https://packagist.org/packages/klintlili/easier-databases)[ Docs](https://github.com/xiongjian/easier-databases/)[ RSS](/packages/klintlili-easier-databases/feed)WikiDiscussions master Synced 1mo ago

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

easier-database
===============

[](#easier-database)

Base is a simple library that makes it easier to work with mysql databases in PHP.

### Features

[](#features)

- Simple \[简单\]
- Intuitive \[直观\]
- Independent \[独立\]
- Secure \[安全\]
- Based on [PDO](http://php.net/manual/en/book.pdo.php)

### Installation

[](#installation)

Include both `Base.php` and `Collection.php` or install [the composer package](https://packagist.org/packages/klintlili/easier-database). See in detail `index.php` Examples in the document.

### Examples

[](#examples)

Connect to a database:

```
# the constructor takes the same parameters as the PDO constructor
$Base = new \klintlili\base\Base('mysql:host=localhost;dbname=example', 'username', 'password');
```

Work with records:

```
# read user 1
$Base->readItem('user', 1);
# update the username of user 1
$Base->updateItem('user', 1, ['username' => 'john.doe']);
# create a user
$Base->createItem('user', ['username' => 'jane.doe', 'email' => 'jane@example.com']);
# delete user 1
$Base->deleteItem('user', 1);
```

Work with collections:

```
# read all users
$Base->find('user')->read();
# read the users that are marked as verified in a desc order
$Base->find('user')->whereEqual('is_verified', 1)->orderDesc('id')->read();
# read the user with the most reputation
$Base->find('user')->limit(1)->orderDesc('reputation')->readRecord();
# mark users 1 and 3 as verified
$Base->find('user')->whereIn('id', [1, 3])->update(['is_verified' => 1]);
# count the users that don't have a location
$Base->find('user')->whereNull('location')->count();
# plain sql conditions are also supported
$Base->find('user')->where('is_verified = ?', [1])->read();
```

Handle relationships:

```
# read the users that have a featured post
$Base->find('user')->has('post')->whereEqual('post.is_featured', 1)->read();
# read the posts of user 1
$Base->find('post')->belongsTo('user')->whereEqual('user.id', 1)->read();
# read the posts that are tagged "php"
$Base->find('post')->hasAndBelongsTo('tag')->whereEqual('tag.name', 'php')->read();
# unconventional FK names are also supported
$Base->find('user')->has('post', 'author_id')->whereEqual('user.id', 1)->read();
```

Execute queries:

```
# read all users
$Base->read('SELECT * FROM user');
# read user 1
$Base->readRecord('SELECT * FROM user WHERE id = ?', [1]);
# read the username of user 1
$Base->readField('SELECT username FROM user WHERE id = ?', [1]);
# read all usernames
$Base->readFields('SELECT username FROM user');
# update all users
$Base->update('UPDATE INTO user SET is_verified = ?', [1]);
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

2115d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cb8b42c426d9b8e32d0afc79d1cacfe3fa3d66d6677fd655116a54cec01e08e?d=identicon)[klintlili](/maintainers/klintlili)

---

Top Contributors

[![klintlili](https://avatars.githubusercontent.com/u/3251749?v=4)](https://github.com/klintlili "klintlili (11 commits)")

---

Tags

phpcomposermysqlproject template

### Embed Badge

![Health badge](/badges/klintlili-easier-databases/health.svg)

```
[![Health](https://phpackages.com/badges/klintlili-easier-databases/health.svg)](https://phpackages.com/packages/klintlili-easier-databases)
```

###  Alternatives

[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[stefangabos/zebra_database

An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.

11812.0k](/packages/stefangabos-zebra-database)[eftec/pdoone

Minimaist procedural PDO wrapper library

1105.9k9](/packages/eftec-pdoone)[matthew-p/docker-server

Universal docker server, Nginx, PHP-FPM, MySql, Redis

112.8k](/packages/matthew-p-docker-server)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)

PHPackages © 2026

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