Skip to content

Commit

Permalink
Increased Version: 1.1.0
Browse files Browse the repository at this point in the history
Implemented Token authentication
  • Loading branch information
Ostico committed Dec 31, 2014
1 parent 430fdb8 commit e050700
Show file tree
Hide file tree
Showing 19 changed files with 513 additions and 189 deletions.
114 changes: 73 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,79 @@ $deleted = $client->recordLoad( $sec_rec->getRid() );
$this->assertEmpty( $deleted );
```

### Get the size of a database ( needs a DB opened )
```php
$client->dbSize();
```

### Get the range of record ids for a cluster
```php
$data = $client->dataClusterDataRange( 9 );
```

### Get the number of records in one or more clusters
```php
$client->dataClusterCount( $client->getTransport()->getClusterMap()->getIdList() );
```

### Get the number of records in an open database
```php
$result = $client->dbCountRecords();
```

### Reload the Database info
This method automatically updates the client Cluster Map.
Can be used after a Class creation or a DataCluster Add/Drop
```php
$reloaded_list = $client->dbReload(); # $reloaded_list === $client->getTransport()->getClusterMap()
```

### Create a new data Cluster
```php
$client->dataClusterAdd( 'new_cluster',
PhpOrient::CLUSTER_TYPE_MEMORY # optional, default: PhpOrient::CLUSTER_TYPE_PHYSICAL
);
```

### Drop a data cluster
```php
$client->dataClusterDrop( 11 );
```

### Persistent Connections ( Session Token )
Since version 27 is introduced an extension to allow use a token based session. This functionality must be enabled on the server config.

- In the first negotiation the client can ask for a token based authentication using the token-auth flag
- The server will reply with a token or an empty string meaning that it not support token based session and is using a old style session.
- For each request the client send the token

When using the token based authentication, the connections can be shared between users of the same server.
```php
$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 );
```

### A GRAPH Example
```php
require "vendor/autoload.php";
Expand Down Expand Up @@ -310,47 +383,6 @@ foreach ( $animal_foods as $food ) {
}
```

### Get the size of a database ( needs a DB opened )
```php
$client->dbSize();
```

### Get the range of record ids for a cluster
```php
$data = $client->dataClusterDataRange( 9 );
```

### Get the number of records in one or more clusters
```php
$client->dataClusterCount( $client->getTransport()->getClusterMap()->getIdList() );
```

### Get the number of records in an open database
```php
$result = $client->dbCountRecords();
```


### Reload the Database info
This method automatically updates the client Cluster Map.
Can be used after a Class creation or a DataCluster Add/Drop
```php
$reloaded_list = $client->dbReload(); # $reloaded_list === $client->getTransport()->getClusterMap()
```

### Create a new data Cluster
```php
$client->dataClusterAdd( 'new_cluster',
PhpOrient::CLUSTER_TYPE_MEMORY # optional, default: PhpOrient::CLUSTER_TYPE_PHYSICAL
);
```

### Drop a data cluster
```php
$client->dataClusterDrop( 11 );
```


## Contributions

- Fork the project.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Ostico/orientdb",
"description": "PHP driver for the OrientDB binary protocol.",
"version": "v1.0.0",
"version": "v1.1.0",
"keywords": [
"orientdb",
"orient db"
Expand Down
16 changes: 8 additions & 8 deletions docs/PhpOrient-Configuration-Constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ Constants


### VERSION

```php
const VERSION = "v0.0.1"

```




### ID

```php
const ID = "1"

```




### NAME

```php
const NAME = "PhpOrient - PHP binary client for OrientDB"

```




### SUPPORTED_PROTOCOL

```php
const SUPPORTED_PROTOCOL = 28

```



Expand Down
78 changes: 56 additions & 22 deletions docs/PhpOrient-PhpOrient.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,73 @@ Constants


### DATABASE_TYPE_DOCUMENT

```php
const DATABASE_TYPE_DOCUMENT = \PhpOrient\Protocols\Common\Constants::DATABASE_TYPE_DOCUMENT

```




### DATABASE_TYPE_GRAPH

```php
const DATABASE_TYPE_GRAPH = \PhpOrient\Protocols\Common\Constants::DATABASE_TYPE_GRAPH

```




### CLUSTER_TYPE_PHYSICAL

```php
const CLUSTER_TYPE_PHYSICAL = \PhpOrient\Protocols\Common\Constants::CLUSTER_TYPE_PHYSICAL

```




### CLUSTER_TYPE_MEMORY

```php
const CLUSTER_TYPE_MEMORY = \PhpOrient\Protocols\Common\Constants::CLUSTER_TYPE_MEMORY

```




### SERIALIZATION_DOCUMENT2CSV

```php
const SERIALIZATION_DOCUMENT2CSV = \PhpOrient\Protocols\Common\Constants::SERIALIZATION_DOCUMENT2CSV

```




### SERIALIZATION_SERIAL_BIN

```php
const SERIALIZATION_SERIAL_BIN = \PhpOrient\Protocols\Common\Constants::SERIALIZATION_SERIAL_BIN

```




### STORAGE_TYPE_LOCAL

```php
const STORAGE_TYPE_LOCAL = \PhpOrient\Protocols\Common\Constants::STORAGE_TYPE_LOCAL

```




### STORAGE_TYPE_PLOCAL

```php
const STORAGE_TYPE_PLOCAL = \PhpOrient\Protocols\Common\Constants::STORAGE_TYPE_PLOCAL

```




### STORAGE_TYPE_MEMORY

```php
const STORAGE_TYPE_MEMORY = \PhpOrient\Protocols\Common\Constants::STORAGE_TYPE_MEMORY

```



Expand Down Expand Up @@ -152,7 +152,7 @@ Methods

### __construct
```php
mixed PhpOrient\PhpOrient::__construct(string $hostname, string $port)
mixed PhpOrient\PhpOrient::__construct(string $hostname, string $port, string $sessionToken)
```
##### Class Constructor

Expand All @@ -164,6 +164,37 @@ Methods
##### Arguments
* $hostname **string** <p>The server host.</p>
* $port **string** <p>The server port.</p>
* $sessionToken **string** <p>An old connection Token to reuse</p>



### setSessionToken
```php
\PhpOrient\PhpOrient PhpOrient\PhpOrient::setSessionToken(string $token)
```
##### Set the session token to re-use old
connection credentials



* Visibility: **public**


##### Arguments
* $token **string**



### getSessionToken
```php
string PhpOrient\PhpOrient::getSessionToken()
```
##### Get the token for this connection



* Visibility: **public**




Expand All @@ -185,7 +216,7 @@ Methods

### getTransport
```php
\PhpOrient\Protocols\Common\AbstractTransport PhpOrient\PhpOrient::getTransport()
\PhpOrient\Protocols\Binary\SocketTransport PhpOrient\PhpOrient::getTransport()
```
##### Gets the transport

Expand Down Expand Up @@ -458,7 +489,7 @@ A callback function is needed

### dbOpen
```php
\PhpOrient\Protocols\Common\ClusterMap PhpOrient\PhpOrient::dbOpen(string $database, string $username, string $password, string $dbType)
\PhpOrient\Protocols\Common\ClusterMap PhpOrient\PhpOrient::dbOpen(string $database, string $username, string $password, array $params)
```
##### Open a Database and perform a connection<br />
if it is not established before
Expand All @@ -472,7 +503,10 @@ if it is not established before
* $database **string**
* $username **string**
* $password **string**
* $dbType **string**
* $params **array** <p>{<code>
'serializationType' => PhpOrient::SERIALIZATION_DOCUMENT2CSV,
'databaseType' => PhpOrient::DATABASE_TYPE_GRAPH
}</code></p>



Expand Down
8 changes: 4 additions & 4 deletions docs/PhpOrient-Protocols-Binary-Data-Bag.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ Constants


### EMBEDDED

```php
const EMBEDDED = 0

```




### TREE

```php
const TREE = 1

```



Expand Down
Loading

0 comments on commit e050700

Please sign in to comment.