hsicard
Joined: 22 Oct 2003
Posts: 17
Posted: 2008-03-26 17:46
Back to top
Reply with quote
|
Hello all,
I would like to block simultaneous editings of a given record.
I found a post from Doug in 2003, explaining how he handled it through a "recycle" bin were versions could be compared in case of multiple editing.
I would prefer locking the record, or at least alerting the second user opening the same record that he is not alone on it.
I imagine it's possible to solve this with triggers. Of course an issue are records potentially tagged as "left opened" while in fact user just went away or connection was lost.
Did someone came up with some solution?
Thanks in advance, and greetings to all,
Hugues
|
marcel
Joined: 28 Jul 2007
Posts: 5
Posted: 2008-06-11 09:46
Back to top
Reply with quote
|
Same question from me.
I have the same situation, but I do not know how to solve...
|
franciscohm
Joined: 08 May 2008
Posts: 33
Posted: 2008-06-12 09:06
Back to top
Reply with quote
|
I am implementing this tool, using a lot of its feautures (export, calendar, languages, etc.). It is great.
I think the block feature should be top of the list in future developments of PHPMyEdit.
Regards
Francisco
|
michal
Joined: 17 Jun 2003
Posts: 537
Location: Slovakia
Posted: 2008-07-08 02:36
Back to top
Reply with quote
|
have a look at pre triggers. however you need some authentification.
|
franciscohm
Joined: 08 May 2008
Posts: 33
Posted: 2009-01-23 04:02
Back to top
Reply with quote
|
Can you please be more specific?
I looked at the documentation and I did not see anything related.
Is there an example somewhere?
Thks
|
doug
Joined: 10 Feb 2003
Posts: 1013
Location: Denver, Colorado (USA)
Posted: 2009-01-24 14:45
Back to top
Reply with quote
|
Implementation of the change log feature in each form is a good idea. If one user overwrites changes made by another user, old values might be retrieved from the changelog table.
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.logging.html
If a method of locking records or tables existed, and if the user did not commit their planned changes, how would you remove the lock?
|
franciscohm
Joined: 08 May 2008
Posts: 33
Posted: 2009-01-24 15:03
Back to top
Reply with quote
|
Thanks Doug
I have the logging method implemented (very nice BTW), but reconstructing data from it, when there can be thousands of transactions, is complicated.
I see your point about blocking and not being able to unblock. It is indeed a problem too...
So I think a good "midpoint" solution might be to have a trigger that after submiting the changes alert us if any other user have done changes while we were editing the register. Hence the pop-up would give us the opportunity to cancel our saving, or to go ahead and overwritte the register.
Does it make sense?
|
doug
Joined: 10 Feb 2003
Posts: 1013
Location: Denver, Colorado (USA)
Posted: 2009-01-24 15:32
Back to top
Reply with quote
|
I don't know if individual records can be locked in MyISAM tables. Search in Google for "php mysql record locking"
http://www.google.com/search?hl=en&q=php+mysql+record+locking&btnG=Google+Search&aq=f&oq=
I did not take time to read all the proposed solutions. It seems that one would want to log the user's name and the LOCK request, and possibly configure a Cron job to run every 5 minutes on the server to search for and report on locks that are older than perhaps 5 minutes (300 seconds). Time entries might easily use PHP's time() function.
| Code: |
CREATE TABLE `locked_records` (
`id` mediumint NOT NULL auto_increment,
`is_active` tinyint(1) not null default '1',
`host_name` char(50) not null default '',
`table_name` char(50) not null default '',
`field_name` char(50) not null default '',
`record_id` varchar(50) not null default '',
`user_name` char(50) not null default '',
`user_ip` char(50) not null default '',
`php_time` int(10) unsigned not null default '0',
`updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
)TYPE=MyISAM DEFAULT CHARSET=utf8 COLLATE utf8_general_ci; |
If locks were recorded to the above schema, the Admin might develop a web page they could reload periodically to view a list of old locks. Such a report should probably include links or a form to enable the Admin to release locks by clicking a link or executing a form which would in turn execute an unlock query.
|
doug
Joined: 10 Feb 2003
Posts: 1013
Location: Denver, Colorado (USA)
Posted: 2009-01-24 15:59
Back to top
Reply with quote
|
With MyISAM the entire table must be locked:
http://lists.mysql.org/mysql/126906
The above link reads, in part: "But usually it is a bad idea to implement application level locks by using database locks. What if I leave my computer? You have to implement some kind of timeout. And so on. Better to implement conflict handling correctly from the start."
|
franciscohm
Joined: 08 May 2008
Posts: 33
Posted: 2009-01-24 17:17
Back to top
Reply with quote
|
Thaks Doug for the tips.
I will explore those ways. :-)
Francisco
|
JammerPro
Joined: 07 Dec 2006
Posts: 33
Posted: 2009-10-19 08:18
Back to top
Reply with quote
|
Thanks Doug and Francisco...
I read through a few of the Google articles, and it seems that Francisco's idea about using triggers is the best solution... if it can be implemented.
Using the log file's timestamp, if the last update to a record was AFTER the user entered "change" mode, the trigger should prevent the user from saving the file and display a message that the file was in use... Once the user returns to view list, etc., he could view the record and enter change mode again to make changes...
Can someone take the first shot at programming this? It would really be a great feature and make PHPMyEdit a true network app... I will be glad to help, but I think there are some of you out there who are more familiar with triggers than I...
|
|
Post new topic
Reply to topic
|