Welcome Guest, Not a member yet? Register   Sign In
How to lock mysql record for modification in update mode with codigniter ??
#1

[eluser]Unknown[/eluser]
Hi All,

I'm looking fot the best way to lock a mysql record for prevent it to updade by an other user when first user is soon in update for it.
I have read about lock for share in Mysql doc but is it a wya to implement it with codigniter and php or ajax ??

Thank's a lot for this answer.



fbm
#2

[eluser]zegulas[/eluser]
http://ellislab.com/codeigniter/user-gui...tions.html
#3

[eluser]Karman de Lange[/eluser]
Seeing that PHP or mysql don't know what other people are busy with on the system, you will need to build this into your application.

The one option is to add column on the record and call it something like "locked_by" and set it to the user who is editing it when you are editing the record.. When the user saves the record, then set to null again.

I would just add date column to say when the record was locked so you can remove remove stale locks later.

Then before editing check if record is being edited and if so, don't allow it.

Hope that make sense










Theme © iAndrew 2016 - Forum software by © MyBB