Using PHPOrient to connect to OrientDB, I'm trying to create a Profile
record and then a User record that refers to it in the same transaction.
The problem is that the temporary record ID (RID) doesn't get updated for
the link. Code snippet:
$client = new PhpOrient('localhost', 2424);
$db_data = $client->dbOpen('mydb', $db_username, $db_password);
$tx->begin();
try {
$new_profile_rec = (new Record())->setOData($profile_data)->setOClass(
'Profile')->setRid(new ID($db_data['id']));
$create_profile = $client->recordCreate($new_profile_rec);
$new_profile_rec = $create_profile->record;
# Link the newly created Profile record to the User
$user_data['profile'] = $new_profile_rec->getRid()->__toString();
$new_user_rec = (new Record())->setOData($user_data)->setOClass('User'
)->setRid(new ID($db_data['id']));
$create_user = $client->recordCreate($new_user_rec);
$tx->attach($create_profile);
$tx->attach($create_user);
$tx->commit();
}
I was hoping that when the optimistic lock RIDs got updated, the link RID
would too. but after executing, I get:
orientdb {db=conveyor}> browse class Profile
----+-----+-------+--------
# |@RID |@CLASS |nickname
----+-----+-------+--------
0 |#11:0|Profile|foobar
----+-----+-------+--------
orientdb {db=conveyor}> browse class User
----+-----+------+-------+-------------
# |@RID |@CLASS|profile|primary-email
----+-----+------+-------+-------------
0 |#13:0|User |#-1:-1 |[email protected]
----+-----+------+-------+-------------
orientdb {db=conveyor}> info class User
Class................: User
Super class..........: Agent
Default cluster......: user (id=13)
Supported cluster ids: [13]
Cluster selection....: round-robin
PROPERTIES
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
NAME | TYPE | LINKED TYPE/CLASS
| MANDATORY | READONLY | NOT NULL | MIN | MAX | COLLATE |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
primary-email | STRING | null
| false | false | false | | | default |
profile | LINK | Profile
| true | false | false | | | default |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
This seems more or less a textbook use of transactions.
Cross posted at
StackOverflow:
http://stackoverflow.com/questions/27790931/how-to-create-a-linked-record-in-a-transaction-with-orientdb-phporient
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.