News for hackers. Stuff that matters.
Re:Show HN: GraPHP, a PHP graph DB web framework by jwatte on Saturday June 06, 2015 @04:20PM (#9672114)
The Readme talks about a bank account. How would transactional update look? If I want to transfer $20 from user A to user B, the following four things need to happen transactionally:

- make sure user A has the necessary funds (reserve)

- put money into user B account (debit)

- take money from user A account (credit)

- commit

At the same time, nobody else must make an operation where they see partial results, and we can't let two operations reserve the same funds in parallel.

I don't see how this use case is supported, but that may just be because I don't know where to look?

Re:Show HN: GraPHP, a PHP graph DB web framework by mikeland86 on Sunday June 07, 2015 @02:49AM (#9673673)
Yeah back account may have been a bad example, but still solvable:

You can use MySQL's SELECT FOR UPDATE (not currently implemented in graphp) to do this transaction safely.

Alternatively, within the framework you can do the reserve amount as a time stamped node and connect it to the user. Then you query for reserve nodes and process them in order.