Just another simple PHP ORM.

View the Project on GitHub taq/torm

You can use it, but don't ask me why I made it. :-)

About TORM

TORM is a simple PHP ORM layer, heavily based on ActiveRecord.

Tell me how it works

The full documentation is on the project wiki, but is simple as this, as long as you follow some conventions (like pluralized table names, auto increment columns etc):

    // include TORM 
    include "torm.php";
    // open the PDO connection and set it
    $con = new PDO("sqlite:database.sqlite3");

    // define your models - an User class will connect to an users table
    class User extends TORM\Model {};
    class Ticket extends TORM\Model {};

    // create some validations
    User::validates("name", array("presence" => true));
    User::validates("email", array("presence" => true));
    User::validates("email", array("uniqueness" => true));
    User::validates("id", array("numericality" => true));

    // create some relations

    // this will create a new user
    $user = new User();
    $user->name  = "John Doe";
    $user->email = "";
    $user->level = 1

    // this will find the user using its primary key
    $user = User::find(1);

    // find some users
    $users = User::where(array("level" => 1));

    // updating users
    User::where(array("level" => 1))->updateAttributes(array("level" => 3));

    // using fluent queries
    $users = User::where(array("level" => 1))->limit(5)->order("name desc");

    // listing the user tickets
    foreach($user->tickets as $ticket)
      echo $ticket->description;

   // show user account info
   echo $user->account->number; 

And many more features. Check the docs.

Authors and Contributors

Created by @taq.

Support or Contact

Check out the project wiki or open an issue.