1. Go to this page and download the library: Download gwin/phporient library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$client = new PhpOrient( 'localhost', 2424 );
$client->setSessionToken( true ); // set true to enable the token based authentication
$clusterID = $client->dbOpen( "GratefulDeadConcerts", 'admin', 'admin' );
$sessionToken = $client->getSessionToken(); // store this token somewhere
//destroy the old client, equals to another user/socket/ip ecc.
unset($client);
// create a new client
$client = new PhpOrient( 'localhost', 2424 );
// set the previous obtained token to re-attach to the old session
$client->setSessionToken( $sessionToken );
//now the dbOpen is not needed to perform database operations
$records = $client->query( 'select * from V limit 10' );
//set the flag again to true if you want to renew the token
$client->setSessionToken( true ); // set true
$clusterID = $client->dbOpen( "GratefulDeadConcerts", 'admin', 'admin' );
$new_sessionToken = $client->getSessionToken();
$this->assertNotEquals( $sessionToken, $new_sessionToken );
use PhpOrient\PhpOrient;
$client = new PhpOrient();
$client->configure( array(
'username' => 'admin',
'password' => 'admin',
'hostname' => 'localhost',
'port' => 2424,
) );
$client->connect();
$client->dbCreate( 'animals', PhpOrient::STORAGE_TYPE_MEMORY );
$client->dbOpen( 'animals', 'admin', 'admin' );
$client->command( 'create class Animal extends V' );
$client->command( "insert into Animal set name = 'rat', specie = 'rodent'" );
$animal = $client->query( "select * from Animal" );
$client->command( 'create class Food extends V' );
$client->command( "insert into Food set name = 'pea', color = 'green'" );
$client->command( 'create class Eat extends E' );
$client->command( "create edge Eat from ( select from Animal where name = 'rat' ) to ( select from Food where name = 'pea' )" );
$pea_eaters = $client->query( "select expand( in( Eat )) from Food where name = 'pea'" );
$animal_foods = $client->query( "select expand( out( Eat )) from Animal" );
foreach ( $animal_foods as $food ) {
$animal = $client->query(
"select name from ( select expand( in('Eat') ) from Food where name = 'pea' )"
)[0];
$this->assertEquals( 'pea', $food[ 'name' ] );
$this->assertEquals( 'green', $food[ 'color' ] );
$this->assertEquals( 'rat', $animal[ 'name' ] );
}