{"id":20381262,"url":"https://github.com/drago-ex/database","last_synced_at":"2026-01-17T20:32:08.652Z","repository":{"id":47036720,"uuid":"44367965","full_name":"drago-ex/database","owner":"drago-ex","description":":floppy_disk: Simple and flexible database abstraction layer built on Dibi for PHP, with support for entities and repositories.","archived":false,"fork":false,"pushed_at":"2026-01-16T08:27:02.000Z","size":47187,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-16T23:33:37.170Z","etag":null,"topics":["database","dibi","nette"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drago-ex.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-10-16T06:58:42.000Z","updated_at":"2026-01-16T08:25:57.000Z","dependencies_parsed_at":"2024-03-20T10:39:30.656Z","dependency_job_id":"6250fa15-f993-4451-90da-b2a382546e41","html_url":"https://github.com/drago-ex/database","commit_stats":{"total_commits":626,"total_committers":3,"mean_commits":"208.66666666666666","dds":"0.011182108626198062","last_synced_commit":"e68948b8896afdb7bb231b1955d08d681ac273fa"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/drago-ex/database","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Fdatabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Fdatabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Fdatabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Fdatabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drago-ex","download_url":"https://codeload.github.com/drago-ex/database/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Fdatabase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492590,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","dibi","nette"],"created_at":"2024-11-15T02:12:44.255Z","updated_at":"2026-01-17T20:32:08.626Z","avatar_url":"https://github.com/drago-ex.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Drago Database\nSimple recurring questions.\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/drago-ex/database/master/license)\n[![PHP version](https://badge.fury.io/ph/drago-ex%2Fdatabase.svg)](https://badge.fury.io/ph/drago-ex%2Fdatabase)\n[![Tests](https://github.com/drago-ex/database/actions/workflows/tests.yml/badge.svg)](https://github.com/drago-ex/database/actions/workflows/tests.yml)\n[![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)\n[![CodeFactor](https://www.codefactor.io/repository/github/drago-ex/database/badge)](https://www.codefactor.io/repository/github/drago-ex/database)\n[![Coverage Status](https://coveralls.io/repos/github/drago-ex/database/badge.svg?branch=master)](https://coveralls.io/github/drago-ex/database?branch=master)\n\n## Requirements\n- PHP \u003e= 8.3\n- Nette Framework\n- dibi\n- Composer\n\n## Knowledge\n- [Dibi - smart database layer for PHP](https://github.com/dg/dibi)\n\n## Installation\n```\ncomposer require drago-ex/database\n```\n\n## Basic Model Example\n```php\n#[Table('table_name', 'primary_key')]\nclass Model\n{\n    use Database;\n}\n```\n\n## Common Queries\nReading records from a table:\n```php\n$this-\u003emodel-\u003eread('*');\n```\n\nFind records by column name:\n```php\n$this-\u003emodel-\u003efind('column, 'value');\n```\n\nGet a record by ID:\n```php\n$this-\u003emodel-\u003eget(1);\n```\n\nDelete a record by column name:\n```php\n$this-\u003emodel-\u003edelete('column, 'value');\n```\n\nSave records as an array (update if `id` is provided):\n```php\n$this-\u003emodel-\u003esave(['column' =\u003e 'value']);\n```\n\n## Using Entities\n```php\nclass SampleEntity extends Drago\\Database\\Entity\n{\n\tpublic const Table = 'name';\n\tpublic const PrimaryKey = 'id';\n\n\tpublic ?int $id = null;\n\tpublic string $sample;\n}\n```\n\nUse the entity in a model:\n```php\n#[From(SampleEntity::Table, SampleEntity::PrimarKey)]\nclass Model\n{\n    use Database;\n}\n```\n\nFetch records as objects:\n```php\n$row = $this-\u003emodel-\u003efind('id', 1)-\u003erecord();\n\n// Accessing properties\necho $row-\u003eid;\necho $row-\u003esample;\n```\n\n## Save Entity Records\nTo save entity data (update record if `id` is present):\n```php\n$entity = new SampleEntity;\n$entity-\u003eid = 1;\n$entity-\u003esample = 'sample';\n\n$this-\u003esave($entity);\n```\n\n# Advanced Features\n## Entity Class for Database Mapping\nYou can use a custom entity class with database mapping:\n```php\n/** @extends Database\u003cSampleEntity\u003e */\n#[From(SampleEntity::Table, SampleEntity::PrimaryKey, class: SampleEntity::class)]\nclass Model\n{\n    use Database;\n}\n\n// Fetch records directly as objects\n$row = $this-\u003emodel-\u003efind('id', 1)-\u003erecord();\n\n// Access the object's properties\necho $row-\u003eid;\necho $row-\u003esample;\n\n// Fetch all records\n$allRecords = $this-\u003emodel-\u003eread('*')-\u003erecordAll();\n```\n\n## Entity Generation\nFor automatic entity generation, consider using the Drago Generator tool: [https://github.com/drago-ex/generator](https://github.com/drago-ex/generator)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrago-ex%2Fdatabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrago-ex%2Fdatabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrago-ex%2Fdatabase/lists"}