I have a data management problem I need to solve, and I'm having a hard time thinking of an efficient, workable solution.
I have an ordered, ranked list I need to manage with PHP and MySql. The list is of the form:
ListID (id of the ranking list), Rank, RecordID(pointer to record in another table).
This would be simple enough, except that the rank order must be dynamically changeable based on the actions of hundreds of users. DB accesses must be minimized to perhaps one per page call, and there are obvious locking issues - i.e. one user may modify the rank order while another user is viewing/preparing to submit a rank change.
The total number of rank records also changes at runtime.
In a stateful application, I'd probably do this with a collection object, i.e.
MyRankObject->promote($rank) (move the record up in rank, re-order all lower ranked records)
Using a linked list, or perhaps a doubly linked list.
I haven't tried storing an object in MySql, can this be done? I've seen the ability to store objects mentioned, but very little documentation exists.
I suppose the order would be:
Function changerank() {
ReadobjectfromDBandLockRecord($ListID);
Changerank($newranknumber);
WriteObjectToDBandUnlock($listid);
}
Can anyone suggest a better alternative? Provide examples of storing objects?
Thanks for any help you may provide...