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

v2.0.6(4mo ago)14.8k4MITPHPPHP &gt;=8.3 &lt;8.9CI passing

Since Oct 15Pushed 4mo 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 1mo ago

READMEChangelog (10)Dependencies (5)Versions (22)Used By (4)

Drago Database
--------------

[](#drago-database)

Simple recurring questions.

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://raw.githubusercontent.com/drago-ex/database/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)[![CodeFactor](https://camo.githubusercontent.com/d604de639dd900f7f04ce38885a5066657a43a52abbb7d3cb6e7e40ee3c1ba41/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f647261676f2d65782f64617461626173652f6261646765)](https://www.codefactor.io/repository/github/drago-ex/database)[![Coverage Status](https://camo.githubusercontent.com/144d947f56ff0768d50138d9fc333607bcfe6a197e82ebaaeecf9ca1c0febbaa/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f647261676f2d65782f64617461626173652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/drago-ex/database?branch=master)

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

[](#requirements)

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

Knowledge
---------

[](#knowledge)

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

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

[](#installation)

```
composer require drago-ex/database

```

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:

```
#[From(SampleEntity::Table, SampleEntity::PrimarKey)]
class Model
{
    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:

```
/** @extends Database */
#[From(SampleEntity::Table, SampleEntity::PrimaryKey, class: SampleEntity::class)]
class Model
{
    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

54

—

FairBetter than 97% of packages

Maintenance78

Regular maintenance activity

Popularity22

Limited adoption so far

Community15

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 ~127 days

Recently: every ~9 days

Total

19

Last Release

123d ago

Major Versions

v1.2.1 → v2.0.02025-01-27

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 (688 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.

93150.7k29](/packages/tharos-leanmapper)

PHPackages © 2026

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