tina4stack/tina4php-orm

Tina4 ORM Module

Maintainers

Package info

github.com/tina4stack/tina4php-orm

pkg:composer/tina4stack/tina4php-orm

Statistics

Installs: 7 034

Dependents: 2

Suggesters: 0

Stars: 2

Open Issues: 0

v2.0.23 2026-03-14 19:36 UTC

README

Object-relational mapping module for the Tina4 PHP framework, providing a simple ORM that works with any Tina4 database driver.

Installation

composer require tina4stack/tina4php-orm

Requirements

  • PHP >= 8.1

Usage

Defining a Model

use Tina4\ORM;

class User extends ORM
{
    public $primaryKey = "id";
    public $tableName = "users";

    public $id;
    public $firstName;
    public $lastName;
    public $email;
}

Loading and Saving Records

// Load a user by primary key
$user = (new User());
$user->load("id = 1");
echo $user->firstName;

// Create a new user
$user = new User();
$user->firstName = "Alice";
$user->lastName = "Smith";
$user->email = "alice@example.com";
$user->save();

Querying Multiple Records

$users = (new User())->select("*", 10)
    ->filter("active = 1")
    ->orderBy("last_name")
    ->asArray();

Testing

composer test

License

MIT - see LICENSE

Our Sponsors

Sponsored with 🩵 by Code Infinity

Code Infinity

Supporting open source communities • Innovate • Code • Empower