2017 © Pedro Peláez
 

library orio

Orio is a good OrientDB query builder based on the PHPOrient.

image

egretos/orio

Orio is a good OrientDB query builder based on the PHPOrient.

  • Sunday, April 8, 2018
  • by egretos
  • Repository
  • 0 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Orio v1.1.0

Orio is a simple OrientDB query builder based on the PHPOrient., (*1)

Tested on Orientdb version 2.1.3, (*2)

Requires

Installation

Using git:

git clone https://github.com/egretos/orio.git

Using composer

Install composer, (*3)

php -r "readfile('https://getcomposer.org/installer');" | php
php composer.phar --no-dev install

Install Orio, (*4)

php composer.phar require "egretos/orio:dev-master" --update-no-dev

Usage

require "vendor/autoload.php";
use Orio\DB;

Connecting to server

$DBconfig = [
    'hostname' => '127.0.0.1',
    'port' => 2424,
    'username' => 'username',
    'password' => 'password',
    'name' => 'DB name',
];
DB::init($DBConfig);

Simple query

Return array of phporient Records, (*5)

$result = DB::command("select from #12:0");

Select by class

Return array of Orio Model, (*6)

$result = DB::select('User')->get();

Getting with custom fields

By default get() return all fields, (*7)

$result = DB::select('User')
    ->get('name'); //one field
$result = DB::select('User')
    ->get(['name', 'email']); //many fields

Getting by condition

Return array of Orio Model, (*8)

$result = DB::select('User')
    ->where('name', 'Joe')
    ->get();

$result = DB::select('User')
    ->where('age', '>', '18')
    ->get();    

Getting one record by rid

Return Orio Model. Usage:, (*9)

use PhpOrient\Protocols\Binary\Data\ID

// 3 variants of definition
$rid = new ID( '#12:0' );
$rid = new ID( 12, 0 );
$rid = new ID( [ 'cluster' => 12, 'position' => 0 ] );

// getting model
$result = DB::byRid($rid);

You can write easier:, (*10)

$result = DB::byRid('#12:0');   

or use select()->one(), (*11)

$result = DB::select('#12:0')->one();

Getting linked Records

The result will be Dmitry's friends., (*12)

$result = DB::select('User')
    ->where('name', 'Dmitry')
    ->linked('Friend')
    ->get();

The result will be all members of the group "Developers", (*13)

$result = DB::select('Group')
    ->where('name', 'Developers')
    ->linked('Member')
    ->get();

The result will be friends of Dmitry, who is a member of the group of "Developers"., (*14)

$result = DB::select('Group')
    ->where('name', 'Developers')
    ->linked('Member')
    ->where('name', 'Dmitry')
    ->linked('Friend')
    ->get();

The result will be all users, who likes Dmitry`s friends, who is a member of the group of "Developers"., (*15)

$result = DB::select('Group')
    ->where('name', 'Developers')
    ->linked('Member')
    ->where('name', 'Dmitry')
    ->linked('Friend')
    ->linked('Likes', 'in')
    ->get();

License

MIT, (*16)

The Versions

08/04 2018

dev-master

9999999-dev

Orio is a good OrientDB query builder based on the PHPOrient.

  Sources   Download

MIT

The Requires

 

orientdb orient db orientechnologies

06/04 2018

dev-dev-master

dev-dev-master

Orio is a good OrientDB query builder based on the PHPOrient.

  Sources   Download

MIT

The Requires

 

orientdb orient db orientechnologies