Jump to content


Photo

PHP MYSQL page requests


  • Please log in to reply
4 replies to this topic

#1 jonny5

jonny5
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 July 2006 - 04:30 PM

I can't seem to find any good documented stuff about this:

When a user calls a php page, and another user calls the same
can this result in database inconsistency?

which part of query's are executed atomically:
none?
just 1 query?
1 php page?

please help me on this one?

thanks!!!

Jonny

;)

#2 Wildbug

Wildbug
  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 13 July 2006 - 08:09 PM

You can use transactional and locking statements if you need atomicity over multiple SQL statements (a transaction).  Otherwise, for a single query, AFAIK, queries are "atomic" by nature.

Of course, I'm refering to SQL commands which change a table in some way (UPDATE, INSERT, or DELETE).  SELECTs would be exempt.

MySQL (I'm assuming MySQL since you're posting in this forum, otherwise PostGRE, Oracle, whatever) handles the database functions.  If a PHP with a table-altering SQL query is requested once, then immediately requested by another user, the inital SQL is carried out, then the second request "sees" the updated table.

Does that answer your question?  There's plenty of information out there on database concurrency, atomicity, transactions, etc.  Much of it is database developer theory and is not of the database user's concern.
Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.

#3 jonny5

jonny5
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 July 2006 - 08:45 PM

Thank you for ur quick response ;)

and what about this:

<?php
//call query to add 1 to some field
//call query to substract 1 to same field
?>

User 1 requests
User 2 requests

can this happen:
u1 add
u2 add
u1 sub
u2sub

or

u1 add
u2 add
u2sub
u1 sub

this can cause inconsistance if you are not using increment or decrement but getting values, changing them and then putting them
so are those queries in 1 php page 1 thing? cause i'm still not getting that part :)

thanks!

#4 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 13 July 2006 - 09:15 PM

I'm worried about the same thing, but was one step behind you in that I was getting/putting the values rather then adding and subtracting them. But your adding/subtracting should work fine, because it doesn't matter what order you do the addition and subtraction.


Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 13 July 2006 - 10:20 PM

Simply assume that anyone can touch the tables at any time, irrespective of the order of the statements across multiple instances of the same script.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users