Skip to content
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

How to obtain the LINKed records in a single query ? #64

Open
fsieduc opened this issue Jan 20, 2016 · 0 comments
Open

How to obtain the LINKed records in a single query ? #64

fsieduc opened this issue Jan 20, 2016 · 0 comments

Comments

@fsieduc
Copy link

fsieduc commented Jan 20, 2016

context : create two records, the second has a LINK property named "friend" pointing to the first record

question : how to fetch both records, in one query, only knowing the second record's RID ?

   <?php
   use PhpOrient\PhpOrient;
   use PhpOrient\Protocols\Binary\Data\Record;
   $client = new PhpOrient('localhost', 2424);
   $client->dbOpen('test', 'root', 'root'); // a Graph database
   $me = $client->recordCreate(Record::fromConfig(['oClass' => 'V', 'oData' => ['label' => 'me']]));
   $you = $client->recordCreate(Record::fromConfig(['oClass' => 'V', 'oData' => ['label' => 'you', 'friend' => ''.$me->getRid()]]));
   <?php
   // and later, only knowing the $youRecordRid
   $records = $client->query("??? {$youRecordRid} ???"); // or any thing else but in one query
   assert(count($records) == 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant