PHPackages                             fishyboat21/extendorm - 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. fishyboat21/extendorm

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

fishyboat21/extendorm
=====================

Simple Lightweight CRUD ORM for PHP 8.4+

2.0.0-alpha.2.3(3mo ago)064GPL-3.0-or-laterPHP

Since Jul 20Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/FishyBoat21/ExtendOrm)[ Packagist](https://packagist.org/packages/fishyboat21/extendorm)[ RSS](/packages/fishyboat21-extendorm/feed)WikiDiscussions main Synced today

READMEChangelog (10)DependenciesVersions (19)Used By (0)

ExtendOrm
=========

[](#extendorm)

[![PHP](https://camo.githubusercontent.com/79b971ffbad852b1b665c8bcc8fa932b272bf356935237560f733fb071033570/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342b2d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://php.net)[![License](https://camo.githubusercontent.com/496514789431619f2335def7e5c832de695cc46025923523c0699b57a1240978/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c2d2d332e302d626c75653f7374796c653d666f722d7468652d6261646765)](LICENSE)[![Composer](https://camo.githubusercontent.com/62a7a84bca4f3421c6ee3f0d095861cfd2b22dc02a6056a743c3272369e88af5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6d706f7365722d6669736879626f617432312f657874656e646f726d2d626c75653f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/fishyboat21/extendorm)

**A Simple, Lightweight CRUD ORM for PHP 8.4+**

---

📖 Table of Contents
-------------------

[](#-table-of-contents)

- [About](#-about)
- [Features](#-features)
- [Requirements](#-requirements)
- [Database Compatibility](#-database-compatibility)
- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [Documentation](#-documentation)
    - [Database Connection](#database-connection)
    - [Defining Models](#defining-models)
    - [Attributes](#attributes)
    - [Relationships](#relationships)
    - [CRUD Operations](#crud-operations)
    - [Query Builder](#query-builder)
    - [Transactions](#transactions)
- [Examples](#-examples)
- [API Reference](#-api-reference)
- [Contributing](#-contributing)
- [License](#-license)

---

📌 About
-------

[](#-about)

**ExtendOrm** is a lightweight, easy-to-use Object-Relational Mapping (ORM) library for PHP 8.4+. It provides a simple yet powerful way to interact with your database using PHP objects, with support for relationships, query building, and transactions.

Perfect for developers who want ORM functionality without the complexity and overhead of heavier solutions like Doctrine or Eloquent.

---

✨ Features
----------

[](#-features)

- 🚀 **Lightweight &amp; Fast** - Minimal overhead, no bloat
- 🔧 **PHP 8.4+ Attributes** - Clean, modern syntax for model definitions
- 🔗 **Relationships** - HasOne, HasMany, BelongsTo support
- 📝 **CRUD Operations** - Simple save, find, update, delete methods
- 🔍 **Query Builder** - Fluent interface for complex queries
- 🔒 **Transactions** - Automatic rollback on errors
- 📦 **Pagination** - Built-in support for paginated results
- 🎯 **Type-Safe** - Leverages PHP's type system
- 💾 **PDO-Based** - Works with MySQL, PostgreSQL, SQLite, and more

---

📋 Requirements
--------------

[](#-requirements)

- **PHP** 8.4 or higher
- **PDO** extension enabled
- **Database**: MySQL or any PDO-compatible database

> ⚠️ **Important Note**: For databases other than MySQL (PostgreSQL, SQLite, etc.), you may need to modify the `QueryBuilder` to handle database-specific SQL syntax (e.g., `LIMIT`/`OFFSET` syntax, identifier quoting, date functions, etc.)

---

🗄️ Database Compatibility
-------------------------

[](#️-database-compatibility)

DatabaseStatusNotes**MySQL**✅ Fully SupportedTested and recommended**MariaDB**✅ Fully SupportedCompatible with MySQL**PostgreSQL**⚠️ Partial SupportMay require `LIMIT`/`OFFSET` syntax changes**SQLite**⚠️ Partial SupportMay require quote identifier changes**SQL Server**❌ Not TestedUnconfirmed compatibility**Oracle**❌ Not TestedUnconfirmed compatibility### Known MySQL-Specific Syntax

[](#known-mysql-specific-syntax)

The QueryBuilder currently uses MySQL syntax for the following:

```
-- LIMIT clause (MySQL style)
LIMIT offset, count

-- Identifier quoting
`column_name`

-- Auto-increment
AUTO_INCREMENT

-- Date/Time functions
NOW(), CURDATE()
```

### For Other Databases

[](#for-other-databases)

If you're using PostgreSQL, SQLite, or another database, you may need to adjust:

1. **LIMIT/OFFSET Syntax**

    ```
    -- MySQL: LIMIT offset, count
    LIMIT 0, 10

    -- PostgreSQL/SQLite: LIMIT count OFFSET offset
    LIMIT 10 OFFSET 0
    ```
2. **Identifier Quoting**

    ```
    -- MySQL: backticks
    `column_name`

    -- PostgreSQL/SQLite: double quotes
    "column_name"
    ```
3. **Auto-increment Primary Keys**

    ```
    -- MySQL: AUTO_INCREMENT
    id INT AUTO_INCREMENT PRIMARY KEY

    -- PostgreSQL: SERIAL
    id SERIAL PRIMARY KEY

    -- SQLite: AUTOINCREMENT
    id INTEGER PRIMARY KEY AUTOINCREMENT
    ```

---

📦 Installation
--------------

[](#-installation)

### Via Composer (Recommended)

[](#via-composer-recommended)

```
composer require fishyboat21/extendorm
```

### Manual Installation

[](#manual-installation)

1. Clone the repository:

```
git clone https://github.com/FishyBoat21/ExtendOrm.git
```

2. Include the autoloader in your project:

```
require_once 'vendor/autoload.php';
```

3. Or manually load the classes:

```
spl_autoload_register(function ($class) {
    $prefix = 'FishyBoat21\\ExtendOrm\\';
    $base_dir = __DIR__ . '/ExtendOrm/src/';

    $len = strlen($prefix);
    if (strncmp($prefix, $class, $len) !== 0) {
        return;
    }

    $relative_class = substr($class, $len);
    $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';

    if (file_exists($file)) {
        require $file;
    }
});
```

---

⚡ Quick Start
-------------

[](#-quick-start)

```
