Bohra Posted August 1, 2012 Share Posted August 1, 2012 ok so i need help in sorting out the easiest way to do this i have 4 diffrent servers from where i can pull data what i want to do is In the first visit it pulls data from server 1 then from the second visit it pulls data from server 2 then from server 3 and then from server 4 and 4 is used again back to 1 right now i am doing this using php random but it wont equally distribute it this way can u tell me how to do this the easiest way ? Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/ Share on other sites More sharing options...
Psycho Posted August 1, 2012 Share Posted August 1, 2012 The only way to do what you are asking would be to save a value each time you execute the script. But, you really have not provided enough information to really provide a full answer. Are the "visits" by the same user? Is the iteration through server supposed to be over the course of a session (if so use a session variable) or across sessions (use a cookie). Or are the "bisits" supposed to be based upon all users as they access the page(s)? If so, you would need to store a value server-side. Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365913 Share on other sites More sharing options...
Bohra Posted August 1, 2012 Author Share Posted August 1, 2012 its more like i am running a mysql loop of sending smses to diffrent users and i have 4 diffrent gateways whose apis i use to send these smses so what i want to do is to the first user it sends through gateway one to the second it send through gateway 2 and this keeps going on and on Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365914 Share on other sites More sharing options...
requinix Posted August 1, 2012 Share Posted August 1, 2012 Why? Do they have some limits on how many you can send? Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365915 Share on other sites More sharing options...
Bohra Posted August 1, 2012 Author Share Posted August 1, 2012 yes they have a daily limit so have to route it through diffrent apis Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365916 Share on other sites More sharing options...
peipst9lker Posted August 1, 2012 Share Posted August 1, 2012 Use a mysql database to the store the last used gateway. Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365917 Share on other sites More sharing options...
Bohra Posted August 1, 2012 Author Share Posted August 1, 2012 wouldnt that increase so many queries ? Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365918 Share on other sites More sharing options...
peipst9lker Posted August 1, 2012 Share Posted August 1, 2012 No? You can handle that in 1 query, which will have to be executed whenever a sms is sent. Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365923 Share on other sites More sharing options...
Bohra Posted August 1, 2012 Author Share Posted August 1, 2012 yeah but first i have to get the data thats 1 query then update the data thats 2nd query and since its a loop of say around 100 numbers isnt that a lot of queries Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365926 Share on other sites More sharing options...
Christian F. Posted August 1, 2012 Share Posted August 1, 2012 That's 2 queries per pageload, which is not a whole lot. Assuming you're sending the message to 100 numbers per pageload, as your post suggests. If you're talking about 100 users sending one message each, then that's still just 2 queries per pageload. Nothing to worry about. If you have the queries inside a loop, then you're most likely doing something wrong. In this case, I'm sure of it. All you need to do, is to get the starting value from the DB before the loop, and save the new one after the loop. Quote Link to comment https://forums.phpfreaks.com/topic/266533-need-help-with-the-easiest-logic/#findComment-1365958 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.