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

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

apitin/database
===============

Database

v1.1.0(2y ago)021MITPHPPHP &gt;=8.0.0

Since Aug 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/wex/apitin-database)[ Packagist](https://packagist.org/packages/apitin/database)[ RSS](/packages/apitin-database/feed)WikiDiscussions master Synced 1w ago

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

Apitin database
===============

[](#apitin-database)

Database (PDO) extensions for `apitin/apitin` with query builder and ORM (as active record)

See  to learn more.
---------------------------------------------------------

[](#see-httpsgithubcomwexapitin-apitin-to-learn-more)

Notice: master branch is still work in progress - only use stable releases!
---------------------------------------------------------------------------

[](#notice-master-branch-is-still-work-in-progress---only-use-stable-releases)

Building query
--------------

[](#building-query)

```
$users = new Apitin\Database\Select('users');
$users->where('is_active = ?', 1);
echo count($users->all()) . PHP_EOL;
```

How to define an active record
------------------------------

[](#how-to-define-an-active-record)

```
#[Table("users")]
#[Column("name")]
#[Column("logged_at", type: Column::TYPE_DATETIME)]
class User extends Apitin\Database\Record
{

}
```

### Table()

[](#table)

```
Table(string $tableName, string $primaryKey = 'id', bool $timeStamps = false, bool $softDelete = false)
```

- If `$timeStamps` is true, you also need columns `created_at` and `updated_at`.
- If `$softDelete` is true, you need column `deleted_at`.

### Column()

[](#column)

```
Column(string $name, string $type = Column::TYPE_STRING, bool $required = false, mixed $default = null)
```

### Column types

[](#column-types)

```
const   TYPE_STRING     = 'string';
const   TYPE_INTEGER    = 'int';
const   TYPE_DECIMAL    = 'decimal';
// Converted to/from boolean  int
const   TYPE_BOOLEAN    = 'bool';
// Converted to/from DateTimeImmutable
const   TYPE_DATETIME   = 'datetime';
// Converted to/from DateTimeImmutable
const   TYPE_DATE       = 'date';
```

### Create user

[](#create-user)

```
$user = User::create([
    'name'  => 'Test User',
]);
$user->save();
```

### Read a single user (with PK=5)

[](#read-a-single-user-with-pk5)

```
$user = User::load(5);
```

### Edit user (with PK=5)

[](#edit-user-with-pk5)

```
$user = User::load(5);
$user->name = 'Updated Test User';
$user->save();
```

### Delete user (with PK=5)

[](#delete-user-with-pk5)

```
$user = User::load(5);
$user->destroy();
```

### Find single user

[](#find-single-user)

```
$user = User::select()->where('name = ?', 'Test User')->first();
```

### Find multiple users

[](#find-multiple-users)

```
$select = User::select()->where('id > 6');
$users = $select->all();
echo count($users) . PHP_EOL;
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Every ~806 days

Total

2

Last Release

942d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  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.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

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

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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