Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 26th, 2003, 10:07 AM
atflm atflm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 atflm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lock tables

Hi all,

I have a script where I made a SELECT and a button to edit each row. This button will open another php script which has 3 options: UPDATE, DELETE or cancel.
The problem is: when a user1 opens a record and if a user2 tries to open the same record, I want that the user2 couldn't open or UPDATE that record. How can I solve this ? With PHP or SQL ? I know the lock only exists for the life of the thread (or until the script ends which is my case, because I have several scripts)

Please help,
Andre

Reply With Quote
  #2  
Old November 26th, 2003, 11:54 AM
Danicek Danicek is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Czech Republic
Posts: 79 Danicek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to Danicek
RE: Lock tables

You should solve it with PHP.
Generaly you can manage locks in most databases. You can lock table with command, however it is not recommanded approach.

Reply With Quote
  #3  
Old November 26th, 2003, 12:10 PM
atflm atflm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 atflm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Lock tables

How can I do that ? I have an idea: create a field status (1 - lock record or entire table, 0 - unlock) in my table. And I will need to have a script that never expires (like a thread). The script should make a verification of this field with a if. This is possible ?

Reply With Quote
  #4  
Old November 26th, 2003, 12:20 PM
Danicek Danicek is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Czech Republic
Posts: 79 Danicek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to Danicek
RE: Lock tables

Well, I am not good enough in PHP to tell you this. Probably someone more expirienced will come.
However one solution could be to add boolean column to your db structure and use it to indicate if row is currently locked or not.
However in high trafic environment this can cause big concurency problems.
So "not in database layer" solution could be better choice. We will see if someone will come and tell us.

Reply With Quote
  #5  
Old November 26th, 2003, 12:30 PM
atflm atflm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 atflm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Lock tables

In this case I don't have high trafic environment. How can I make a script that never expires. My scripts only had a few seconds of life (only make a SELECT or an UPDATE).

Reply With Quote
  #6  
Old November 26th, 2003, 12:36 PM
Danicek Danicek is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Czech Republic
Posts: 79 Danicek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to Danicek
RE: Lock tables

So if you have not high trafic environment. Just add something like "Locked" collumn to your table and set it to 0 (= not locked). Each time someone will start to work with certain row, set "Locked" collumn in this row with update to 1 (locked).
Each time someone will try to start to work with certain row, check if it has 0 value in "Locked" collumn.

Reply With Quote
  #7  
Old November 26th, 2003, 05:40 PM
atflm atflm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 atflm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Lock tables

I already solved this problem. Now I've got a doubt with Javascript. When I opens the php script to edit, I change my field status to 1 to lock the registry and I've got 3 buttons: UPDATE, DELETE or cancel. If I press one of this buttons I change my field status to 0 to unlock the registry. Now if I press the close button in the right corner of the browse, the status field doesn't change and I need to change it to 0. How can I do this ?

Reply With Quote
  #8  
Old November 26th, 2003, 05:44 PM
zackcoburn zackcoburn is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 184 zackcoburn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Lock tables


Reply With Quote
  #9  
Old November 26th, 2003, 05:55 PM
atflm atflm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 atflm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Lock tables

Well, I already lock the table. My doubt is about Javascrip, I don't if here is the best place to put this question. How can I know if anyone press in the close button of the browser ?

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Lock tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 9 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek