A fast PHP driver for the OrientDB binary protocol.




Build Status

A fast PHP driver for the OrientDB binary protocol.

status: alpha This is work in progress, alpha quality software. Please report any bugs you find so that we can improve the library for everyone.


Configuring the client

$client = new OrientDB\Client([
  'hostname' => 'localhost',
  'port' => 2424,
  'username' => 'root',
  'password' => 'yourpassword'

List the databases on the server.

foreach($client->getDatabases() as $name => $db) {
  echo $name, "<br>";

Use a particular database

$db = $client->getDatabases()->mydatabase;

Use a particular database, with custom credentials

$db = $client->getDatabases()->mydatabase;
$db->username = 'me';
$db->password = 'mypassword';

Create a new database

$db = $client->getDatabases()->create('mydatabase', 'plocal');

Drop an existing database

$client->getDatabases()->drop('mydatabase', 'plocal');

Query builder: Insert record

$record = $db->insert(['name' => 'Me'])->into('MyClass')->one();

Query builder: Update record

$db->update('MyClass')->set(['name' => 'Charles'])->where(['name' => 'Me'])->one();

Query builder: Delete record

$db->delete('MyClass')->where(['name' => 'Charles'])->one();

Query builder: Select records

$results = $db->select('name')->from('OUser')->groupBy('status')->all();

Query builder: Select records with fetch plan.

$results = $db->select()->from('OUser')->where(['status' => 'ACTIVE'])->fetch(['roles' => 2])->all();

Query builder: Select expression

$totalUsers = $db->select('count(*)')->from('OUser')->scalar();

Query builder: Traverse records

$rows = $db->traverse()->from('OUser');

List all the clusters in the database.

foreach($db->clusters as $name => $cluster) {
  echo 'Cluster '.$name.' has '.$cluster->count()." records.\n";

List all the classes in the database.

foreach($db->classes as $name => $class) {
  echo $name."\n";


MIT, see