PHPackages                             vaibhavpandeyvpz/datum - 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. vaibhavpandeyvpz/datum

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

vaibhavpandeyvpz/datum
======================

A simple Active Record ORM for PHP built on top of databoss

1.2.1(3mo ago)2321MITPHPPHP ^8.2CI passing

Since Dec 28Pushed 3mo agoCompare

[ Source](https://github.com/vaibhavpandeyvpz/datum)[ Packagist](https://packagist.org/packages/vaibhavpandeyvpz/datum)[ RSS](/packages/vaibhavpandeyvpz-datum/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (5)Used By (1)

Datum
=====

[](#datum)

[![Tests](https://github.com/vaibhavpandeyvpz/datum/workflows/Tests/badge.svg)](https://github.com/vaibhavpandeyvpz/datum/actions)[![PHP Version](https://camo.githubusercontent.com/c5e8da782b1a0673c08b4f474108036d2cc973470eed2d5d89d48e8c8475eee6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Code Coverage](https://camo.githubusercontent.com/bd63309fd9fa3c09fac5db30229dd07c09b001230f0b7fb62ec98dc91b2f7208/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d39302532352d627269676874677265656e2e737667)](https://github.com/vaibhavpandeyvpz/datum)

A simple Active Record ORM for PHP built on top of [vaibhavpandeyvpz/databoss](https://github.com/vaibhavpandeyvpz/databoss).

Features
--------

[](#features)

- **Active Record Pattern**: Simple, intuitive model definitions
- **Fluent Query Builder**: Chain methods like `where()`, `sort()`, `limit()`, `offset()`, `get()`, `first()`
- **Relationships**: Support for `one` (has one), `many` (has many), `owner` (belongs to), and `owners` (belongs to many) relationships
- **Attribute Casting**: Automatic type conversion for DateTime, arrays, JSON, integers, floats, and booleans
- **Automatic Timestamps**: Automatically manages `created_at` and `updated_at` timestamps (enabled by default)
- **UUID Primary Keys**: Support for UUID primary keys with automatic UUID v4 generation
- **Lazy Connection Loading**: Connection factory support for lazy database connection creation
- **PSR-14 Event Dispatcher**: Model lifecycle events (creating, created, updating, updated, deleting, deleted, saving, saved)
- **Built on Databoss**: Leverages the powerful databoss filtering syntax
- **Multi-Database Support**: Works with MySQL, PostgreSQL, SQLite, and SQL Server
- **Type-safe**: Full PHP 8.2+ type declarations
- **Well Tested**: 90%+ code coverage with comprehensive test suite

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

[](#requirements)

- PHP &gt;= 8.2
- PDO extension
- One of: `ext-pdo_mysql`, `ext-pdo_pgsql`, `ext-pdo_sqlite`, or `ext-pdo_sqlsrv` (depending on your database)

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

[](#installation)

```
composer require vaibhavpandeyvpz/datum
```

Or if you want to install the databoss dependency separately:

```
composer require vaibhavpandeyvpz/databoss ^2.1
composer require vaibhavpandeyvpz/datum
```

Quick Start
-----------

[](#quick-start)

### Setting Up the Connection

[](#setting-up-the-connection)

You can set the connection directly or use a connection factory for lazy connection creation using the `connect()` method:

#### Direct Connection

[](#direct-connection)

```
