1.5.0 2017-01-10 03:20 UTC

This package is not auto-updated.

Last update: 2023-09-30 19:36:43 UTC


The TransactdORMPHP is PHP ORM library using the Transactd plugin for MySQL/MariaDB. It is a fastest ORM for PHP.


  • High-speed database access.
  • A Model is possible to high speed access to properties.
  • It can be used as the ActiveRecord.
  • Easy to migrate from the Laravel in similar interface to Laravel5.
  • It does not depend on any framework. Also available on any PHP framework.

Execution environment





  • Install via the composer.
$ cd [yourProjectDirectory]
$ composer require Trnasactd/orm
  • Add the following to the beginning of your code.(If not added.)
require __DIR__ . '/vendor/autoload.php'


  1. Download form the GitHub.

  2. Extruct to your project directry.

  3. Add the following to the beginning of your code.

require __DIR__ . '/TransactdORMPHP-master/src/Require.php'

Connect to databases

Master and Slave host, these are possible to same host. If you specify a different host, the write operation is the master and the read operation is processed by the slave.

Laravel 5.1 above

  • Add the following class to your config/app.php service providers list.
  • Add following parameters to your .env file.
// Master and Slave. These are possible to same host.


  • Add the following code to your application code at beggining.
class_alias('Transactd\DatabaseManager', 'DB');
$masterUri = 'tdap://yousername@your_master_host/your_database?&pwd=xxxx';
$slaveUri = 'tdap://yousername@your_slave_host/your_database?&pwd=xxxx';
DB::connect($masterUri, $slaveUri);

Usage example

Table names and field names follow the rules of ActiveRecord.

require __DIR__ . '/TransactdORMPHP-master/src/Require.php'

use BizStation\Transactd\Transactd;
use BizStation\Transactd\Database;
use Transactd\Model;

class Group extends Model
	public function customers()
		this->hasMany('Customer', 'group')

class Customer extends Model
	public function group()
		return $this->belongsTo('Group', 'group', 'id');

// Connect to databases (Master and Slave. These are possible to same host.)
class_alias('Transactd\DatabaseManager', 'DB');
$masterUri = 'tdap://root@masterhost/test?pwd=xxxx';
$slaveUri = 'tdap://root@slavehost/test?pwd=xxxx';
DB::connect($masterUri, $slaveUri);

// Get all customers
$customers = Customer::all();
echo 'The first customer's id = '. $customers[0]->id;

// Get all customers with group relationship in a snapshot.
$customers = Customer::with('group')->all();

// Find a customer id = 1
$customer = Customer::find(1);
echo 'The customer name is '. $customer->name;

// Find customers that group number is 3.
// Transactd query are required that index number and keyValue for start of search.
$customers = Customer::index(1)->keyValue(3)->where('group','=', 3)->get();
echo 'There are '.count($customers).' customers in Group 3.';

// Get a group ralationship from a customer. (belongsTo)
$customer = Customer::find(1);
$group = $customer->group;

// Get customers ralationship from a group. (hasMany)
$group = Group::find(1);
$customers = $group->customers;

// Save a new customer.
$customer = new Customer();
$customer->id = 0;  //autoincrement
$customer->group = 1;

// Delete a customer in a transaction.

// Using native API
$db = DB::master();
$tb = $db->openTable('customrs');


  1. Tutorial
  2. Trnasactd ORM for PHP API
  3. Trnasactd Client PHP API

Bug reporting, requests and questions

If you have any bug-reporting, requests or questions, please send it to Issues tracker on github.


This package is licensed under the MIT license.