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

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

fullstackpe/micro-db
====================

Simple orm library

1.1.1(7y ago)099MITPHPPHP &gt;=7.0.0

Since Dec 19Pushed 7y ago2 watchersCompare

[ Source](https://github.com/marcomilon/micro-db)[ Packagist](https://packagist.org/packages/fullstackpe/micro-db)[ RSS](/packages/fullstackpe-micro-db/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

Micro-db
========

[](#micro-db)

[![Latest Stable Version](https://camo.githubusercontent.com/8cc5621b75a38a825681edf70be3ad8993ef955d69792ea6c39d19da3bc85bcf/68747470733a2f2f706f7365722e707567782e6f72672f66756c6c737461636b70652f6d6963726f2d64622f762f737461626c65)](https://packagist.org/packages/fullstackpe/micro-db) [![Build Status](https://camo.githubusercontent.com/d74cd17e4edef1d8f678656d919a18550ddbb8d748f1d3f42a643bf739dfb7b9/68747470733a2f2f7472617669732d63692e6f72672f6d6172636f6d696c6f6e2f6d6963726f2d64622e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/marcomilon/micro-db)

Micro-db is a lightweight ORM library.

### Installation

[](#installation)

First you need to install Composer. You may do so by following the instructions at [getcomposer.org](https://getcomposer.org/download/). Then run

> composer require fullstackpe/micro-db

If you prefer you can create a composer.json in your project folder.

```
{
    "require": {
        "fullstackpe/micro-db": "^1.1"
    }
}
```

Then run the command

> composer install

### The ActiveRecord Class

[](#the-activerecord-class)

If you have a table called `book`. You need to create an active record Class called `Book` that extends the Class `micro\db\ActiveRecord`. The class `Book`needs to implement two methods: tableName() and dbConnection().

#### Example

[](#example)

```
use micro\db\ActiveRecord;

class Book extends ActiveRecord {

    public static function tableName()
    {
        return 'book';
    }

    public static function dbConnection()
    {
        $servername = "127.0.0.1";
        $username = "root";
        $password = "fullstack";
        $database = "mysql";

        return new \micro\db\Connection($servername, $username, $password, $database);
    }
}
```

Then you can instantiate the class.

#### Example

[](#example-1)

```
// Create a new book
$book = new Book();
$book->title('This is the title of my book');
$book->save();

// fetchs all books
$books = Book::find()->all();
foreach($books as $book) {
    echo $book->title;
}

// search for one book
$condition = [
    ['=', 'id', '1']
];
$book = Book::find()->where($condition)->one();
echo $book->title
```

### The QueryBuilder Class

[](#the-querybuilder-class)

The queryBuilder class builds a Sql statement.

#### Example

[](#example-2)

```
$table = 'home';
$qB = new \micro\db\QueryBuilder();
$columns = [
    'id',
    'name',
    'address'
];
$sql = $qB->select($columns)->from($table)->getRawSql();
```

The variable `$sql` is equal to the string "SELECT `id`, `name`, `address` FROM `home`".

### Contribution

[](#contribution)

Feel free to contribute! Just create a new issue or a new pull request.

### License

[](#license)

This library is released under the MIT License.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

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

Every ~134 days

Total

3

Last Release

2801d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05347140f9f9393aec4fb7b984b5f8ab4b18f6c40ccc1cb7c8a1b0223835a720?d=identicon)[marcomilon](/maintainers/marcomilon)

---

Top Contributors

[![marcomilon](https://avatars.githubusercontent.com/u/867205?v=4)](https://github.com/marcomilon "marcomilon (36 commits)")

---

Tags

activerecordcomposerdatabaselightweight-orm-librarymysqlormphpquery-builderorm

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

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

Symfony DoctrineBundle

4.8k241.3M3.3k](/packages/doctrine-doctrine-bundle)[doctrine/persistence

The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.

4.1k286.5M762](/packages/doctrine-persistence)[gedmo/doctrine-extensions

Doctrine behavioral extensions

4.1k118.8M366](/packages/gedmo-doctrine-extensions)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[beberlei/doctrineextensions

A set of extensions to Doctrine 2 that add support for additional query functions available in MySQL, Oracle, PostgreSQL and SQLite.

2.1k75.1M146](/packages/beberlei-doctrineextensions)

PHPackages © 2026

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