Ostico / PhpOrient

PhpOrient - Official Php driver based on the binary protocol of OrientDB.
Other
68 stars 37 forks source link

FetchPlan and PhpOrient\Protocols\Binary\Data\Bag #13

Open SpareShade opened 9 years ago

SpareShade commented 9 years ago

Hi, thank you for providing this package.

I am having a difficulty understanding how to get fetched relationships from the returned record (PhpOrient\Protocols\Binary\Data\Record). They appear to be serialized in PhpOrient\Protocols\Binary\Data\Bag object.

any help would be much appreciated :) ...

Ostico commented 9 years ago

Hi, i think that this example can help you: Incorrect RID position, when fetched into Bag object

was a bug reported by @aurelijusb

SpareShade commented 9 years ago

Hello, thank you for such a fast reply :) . I have had a look at all the issues/examples but I just can't figure it out.

This is what I have: Person (V) has out edge LivesAt(E) pointing to Address(V)

$callback = function( $record) { var_dump($record) }
$q = $PhpOrientClient->queryAsync(
     'select from Person limit 1',
     ['fetch_plan' =>  '*:-1', '_callback' => $callback]
);

when I var_dump($record) in the callback i get the fetched relationship(s) ie. LivesAt and the Address and if I var_dump($q) I get the Person ...

I just cannot figure out how to synthesize Person with its LivesAt edges ?? I've tried and tried but it just doesn't work ...

Ostico commented 9 years ago

Ah ok, i think you need something like this:

A graph example from @rochacbruno on pyorient

SpareShade commented 9 years ago

Thanks for that, I had tried it but it seems to query the db anew for each expand.