Skip to content

Implemented basic edges support #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 15, 2012

Conversation

frankmayer
Copy link
Contributor

Creating an edge, and querying for edges, inedges, outedges is implemented.

The Edge and EdgeHandler both inherit from Document and DocumentHandler respectively and can use most of the functions supplied by Document and DocumentHandler.

Edges are supported from ArangoDB 1.0 upwards.
In ArangoDB 1.1 Edges need to be inserted in special edge-collections. (collection type=3).

This is done like this:

$collectionHandler = new \triagens\ArangoDb\CollectionHandler($connection);
$edgeCollection = new \triagens\ArangoDb\Collection();
$edgeCollection->setName('EdgeCollection');
$edgeCollection->set('type', 3);
$collectionHandler->create($edgeCollection);

A graph would be created like this:

$document1 = new \triagens\ArangoDb\Document();
$document2 = new \triagens\ArangoDb\Document();
$documentHandler = new \triagens\ArangoDb\DocumentHandler($connection);
$document1->someAttribute = 'someValue1';
$document2->someAttribute = 'someValue2';

$edgeDocument = new \triagens\ArangoDb\Edge();
$edgeDocumentHandler = new \triagens\ArangoDb\EdgeHandler($connection);

$documentId1 = $documentHandler->save('ArangoDBPHPTestSuiteTestCollection01', $document1);
$documentId2 = $documentHandler->save('ArangoDBPHPTestSuiteTestCollection01', $document2);
$documentHandle1=$document1->getHandle();
$documentHandle2=$document2->getHandle();

$edgeDocument->set('label','knows');
$edgeDocumentId = $edgeDocumentHandler->saveEdge($edgeCollection->getId(), $documentHandle1, $documentHandle2, $edgeDocument);

Signed-off-by: Frank Mayer <frank@frankmayer.net>
Theres more to be done

Signed-off-by: Frank Mayer <frank@frankmayer.net>
Tests written and pass on ArangoDB 1.0 & 1.1

Signed-off-by: Frank Mayer <frank@frankmayer.net>
Signed-off-by: Frank Mayer <frank@frankmayer.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants