titon/model

This package is abandoned and no longer maintained. No replacement package was suggested.

The Titon model package provides an active record style approach to database CRUD functionality.

0.3.2 2014-02-24 06:15 UTC

This package is auto-updated.

Last update: 2022-02-01 12:29:51 UTC


README

The Titon model package provides an active record style approach to database CRUD functionality. Further provides data validation, field protection, and table relationship support.

$user = User::find(1);
$user->username = 'foobar';
$user->save();

Outside of the active record structure, a handful of static methods can be used for basic database functionality, like inserting, deleting, selecting, and updating.

User::insert(['username' => 'foobar']);
User::select()->all();
User::deleteBy(1);
User::updateBy(1, ['username' => 'foobar']);

A full list of database features can be found under the DB package.

Alongside the DBAL is an extensible object relational mapper (ORM) that permits repositories (database tables) to relate records to other repository records through foreign keys. Related data can also be saved automatically while saving parent records, and can be pulled in automatically and easily through the query builder. The ORM is fully compatible with schemaless/NoSQL database drivers.

$users->hasOne('Profile', 'App\Repository\Profile', 'profile_id');

$entity = $users->select()->with('Profile')->where('id', 1)->first();

Features

  • Model - Active record model
    • Relationships
    • Validation
    • Data filling
    • Data guarding
    • Accessors
    • Mutators

Dependencies

  • DB

Requirements

  • PHP 5.4.0

Upcoming Features

  • Polymorphic relations
  • Refactored lazy/eager loading of relations