oceans Posted May 12, 2007 Share Posted May 12, 2007 Dear People, I need a very important advice. My experience: I have done databases using VB, Winsock. It is relatively tough, but you get all flexibility & security is iron clad as you can define your protocol, and “malicious data” dumps, make multi thread to become single thread FIFO. I need advice: Is the PHP-MySQL multi threaded? That means, at any one instance, will MySQL be serving a more then one page? My intension; though MySQL can server (n number) of pages at any instance, it should NOT serve more then one page simultaneously. Reason, what happens if one table gets “updating”, and second comes for another process on the same table? Is the PHP-MySQL FIFO. Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/ Share on other sites More sharing options...
taith Posted May 12, 2007 Share Posted May 12, 2007 mysql can access information to more then one computer at the same time... besides... mysql's connections can take litterally milliseconds to finish... the chance of 2 computers connecting at the same time would be a once in a lifetime fluke... Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251215 Share on other sites More sharing options...
oceans Posted May 12, 2007 Author Share Posted May 12, 2007 Friend, Thanks, this is very important for me, thus I will leave this thread open Please share and guide me, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251217 Share on other sites More sharing options...
chronister Posted May 12, 2007 Share Posted May 12, 2007 That is a good question. I am not sure as to the actual answer to your question, however it would not be very hard to "lock" a table when needed. If I were doing this, then I would do it like so. 1 field in the tables you want to lock called locked. It accepts a 0 or 1. 0=no 1=yes Generally when you want to edit records, it is a 2 part process. 1st you have to get the data from the database and display it in a form or whatever. the second part is the actual update process. I would simply make the default locked state 0. When you grab the data from the database to edit it, you check and make sure the data is in 0 (unlocked state). If so, get the data and run a query to change the locked state to a 1 for that record. When you update it, you set that state back to 0. It sounds like a lot of extra work, but it is actually very simple and would only require 4-5 extra lines of code. Hope this helps ya some. Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251218 Share on other sites More sharing options...
oceans Posted May 13, 2007 Author Share Posted May 13, 2007 I do not is it right for me ask the following question, can you script a small example, Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251752 Share on other sites More sharing options...
chronister Posted May 13, 2007 Share Posted May 13, 2007 do you know how to do basic select queries and update queries? Do you know how to do an if / else statement?? I am happy to help with problems in coding, but no one in this forum really wants to write your scripts for you. Here is the basic principle. <?php // run query and get data you want // use while loop to go through the results // set variables for each element in the database you want to work with // run if / else statement to see if table.locked is set to 1 // if it's a 1, the table is locked // else it's a 0 it is not locked // get all data you want to edit // run update query and set locked to 1 for the row you are working with // make changes in form and update // when you update the information in the database, set locked back to 0 and exit the code. // your data is now updated and the lock has been set back to unlocked state ?> Just basically take the comments and create the proper code for each line. You may have to change some things, but its pretty much laid out there Nate Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251759 Share on other sites More sharing options...
oceans Posted May 13, 2007 Author Share Posted May 13, 2007 Dear Chronister, You misunderstood me , I was requesting for the "locking database command syntex" I will try inserting into my code. One question here, if two request comes, while one is being worked (locked), (i) will the second waits for the first to finish or (ii) it just sees it is locked and does nothing and gets out. Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251775 Share on other sites More sharing options...
chronister Posted May 13, 2007 Share Posted May 13, 2007 it will do whatever you want it to do.. You specify what is to happen inside your code. There is no locking database command. I am simply suggesting that you can place a field in your database called locked and make it so a 0 is unlocked, and a 1 is locked. Write your code to look at that piece of data and if it is 0 make it so you can do whatever you want with that data, if it is 1, it means it is locked. You would then create code to handle it however you want. If you want a message to appear saying "Sorry, this field is locked... Please try again later" you would do something like this.. <?php if($locked_db_field =0){ // $locked_db_field should be changed to YOUR variable for this field // grab the data and do what you want with it } else { echo 'Sorry, this field is locked... Please try again later'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251779 Share on other sites More sharing options...
corbin Posted May 13, 2007 Share Posted May 13, 2007 You could use a simple while loop and a sleep or usleep call to avoid giving your user an error.... It could potentially exceed the execution time though.... Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251801 Share on other sites More sharing options...
oceans Posted May 13, 2007 Author Share Posted May 13, 2007 I use to do these jobs in my server side. When I am doing PHP I presumed that I am only doing client and have no control over the server. Yes I can implement your suggestion, but can you suggest a "Sleep" code which does not consumes rosource while looping, I had this probelm in VB, eventually I came up with a timered loop which almost uses 0 resource while looping Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-251830 Share on other sites More sharing options...
chronister Posted May 13, 2007 Share Posted May 13, 2007 PHP is a server side language. It has nothing to do with client side. Once it reaches the client, it has done all that it is going to do, and is echoing out pure html. Javascript is client side. You cannot do server side stuff with javascript (but you can with AJAX) Quote Link to comment https://forums.phpfreaks.com/topic/51048-help-on-fundamental/#findComment-252150 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.