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

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

drago-ex/database
=================

Connecting to database for Nette Framework

v3.0.5(1w ago)15.4k7MITPHPPHP &gt;=8.3 &lt;9CI passing

Since Oct 15Pushed 1w ago1 watchersCompare

[ Source](https://github.com/drago-ex/database)[ Packagist](https://packagist.org/packages/drago-ex/database)[ RSS](/packages/drago-ex-database/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (20)Versions (29)Used By (7)

Drago Database
==============

[](#drago-database)

Simple database helpers built on top of Dibi.

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://github.com/drago-ex/database/blob/master/license)[![PHP version](https://camo.githubusercontent.com/4d1240d330837e3d21f8b14eb19809cd3846ed7e7fc94bbff899f5f05bc282aa/68747470733a2f2f62616467652e667572792e696f2f70682f647261676f2d657825324664617461626173652e737667)](https://badge.fury.io/ph/drago-ex%2Fdatabase)[![Tests](https://github.com/drago-ex/database/actions/workflows/tests.yml/badge.svg)](https://github.com/drago-ex/database/actions/workflows/tests.yml)[![Coding Style](https://github.com/drago-ex/database/actions/workflows/coding-style.yml/badge.svg)](https://github.com/drago-ex/database/actions/workflows/coding-style.yml)

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

[](#requirements)

- PHP &gt;= 8.3
- Nette Framework
- dibi
- Composer

Installation
------------

[](#installation)

```
composer require drago-ex/database

```

Knowledge
---------

[](#knowledge)

- [Dibi - smart database layer for PHP](https://github.com/dg/dibi)

Basic Model Example
-------------------

[](#basic-model-example)

```
#[Table('table_name', 'primary_key')]
class Model
{
    use Database;
}
```

Common Queries
--------------

[](#common-queries)

Reading records from a table:

```
$this->model->read('*');
```

Find records by column name:

```
$this->model->find('column', 'value');
```

Get a record by ID:

```
$this->model->get(1);
```

Delete a record by column name:

```
$this->model->delete('column', 'value');
```

Save records as an array (update if `id` is provided):

```
$this->model->save(['column' => 'value']);
```

Using Entities
--------------

[](#using-entities)

```
class SampleEntity extends Drago\Database\Entity
{
	public const Table = 'name';
	public const PrimaryKey = 'id';

	public ?int $id = null;
	public string $sample;
}
```

Use the entity in a model:

```
#[Table(SampleEntity::Table, SampleEntity::PrimaryKey, entity: SampleEntity::class)]
class Model
{
	/** @phpstan-use Database */
    use Database;
}
```

Fetch records as objects:

```
$row = $this->model->find('id', 1)->record();

// Accessing properties
echo $row->id;
echo $row->sample;
```

Save Entity Records
-------------------

[](#save-entity-records)

To save entity data (update record if `id` is present):

```
$entity = new SampleEntity;
$entity->id = 1;
$entity->sample = 'sample';

$this->save($entity);
```

Advanced Features
-----------------

[](#advanced-features)

### Entity Class for Database Mapping

[](#entity-class-for-database-mapping)

You can use a custom entity class with database mapping:

```
#[Table(SampleEntity::Table, SampleEntity::PrimaryKey, entity: SampleEntity::class)]
class Model
{
	/** @phpstan-use Database */
    use Database;
}

// Fetch records directly as objects
$row = $this->model->find('id', 1)->record();

// Access the object's properties
echo $row->id;
echo $row->sample;

// Fetch all records
$allRecords = $this->model->read('*')->recordAll();
```

### Entity Generation

[](#entity-generation)

For automatic entity generation, consider using the Drago Generator tool:

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance98

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 99.9% 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 ~97 days

Recently: every ~6 days

Total

26

Last Release

7d ago

Major Versions

v1.2.1 → v2.0.02025-01-27

v2.0.6 → v3.0.02026-05-30

v2.0.7 → v3.0.42026-06-16

PHP version history (7 changes)v1.0.0PHP &gt;=7.1

v1.0.5PHP &gt;=7.4

v1.0.8PHP &gt;=8.0

v1.0.11PHP &gt;=8.1

v1.0.15PHP &gt;=8.1 &lt;8.4

v1.2.1PHP &gt;=8.3 &lt;9

v2.0.0PHP &gt;=8.3 &lt;8.9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5998929?v=4)[Zdeněk Papučík](/maintainers/accgit)[@accgit](https://github.com/accgit)

---

Top Contributors

[![accgit](https://avatars.githubusercontent.com/u/5998929?v=4)](https://github.com/accgit "accgit (717 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")

---

Tags

databasedibinette

### Embed Badge

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

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

###  Alternatives

[tharos/leanmapper

Tiny ORM based on powerful Dibi database abstraction library for PHP.

93157.3k32](/packages/tharos-leanmapper)

PHPackages © 2026

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