ala888 Posted September 1, 2014 Share Posted September 1, 2014 I have 10 serversuploads from users are passed in round robin fashion to each sql server. There is a main page where the top 20 "liked" content is displayed.How do I go about selecting the top 20 liked results but from 10 different servers. Im really stumped here. Is it even possible to do an "ORDER BY"-like statement with the returned mysqli_result objects in php? Link to comment Share on other sites More sharing options...
niche Posted September 1, 2014 Share Posted September 1, 2014 do you mean servers or tables? Link to comment Share on other sites More sharing options...
ala888 Posted September 1, 2014 Author Share Posted September 1, 2014 (edited) i have 10 servers. on different hosts and different ip addresses. and I need a way to do an ORDER BY `column_name` by the differing mysqli_result objects returned from each server 10 sql queries from diff servers => make into a temp table => order by => get 20 results Edited September 1, 2014 by ala888 Link to comment Share on other sites More sharing options...
niche Posted September 1, 2014 Share Posted September 1, 2014 I've never encountered that situation. I'll monitor this topic. It's a very interesting question. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 2, 2014 Share Posted September 2, 2014 A database connection is a connection to a single server, not 10 servers. You need to aggregate the data in one place and then work on it. 1 Link to comment Share on other sites More sharing options...
niche Posted September 2, 2014 Share Posted September 2, 2014 (edited) Glad to hear that jsg (though probably not the answer the OP was hoping for) . I couldn't imagine how to do that. Edited September 2, 2014 by niche Link to comment Share on other sites More sharing options...
thescientist Posted September 2, 2014 Share Posted September 2, 2014 One way could be to have a single database which has a cron job running on its server that pulls in all the data and stores it, so then the application only has to look in one place. Link to comment Share on other sites More sharing options...
ala888 Posted September 8, 2014 Author Share Posted September 8, 2014 (edited) One way could be to have a single database which has a cron job running on its server that pulls in all the data and stores it, so then the application only has to look in one place. mind giving me like a really simple example of that? how would that go ?sql = "select ..."mysqli_result = mysqli_query($client,$sql); INSERT INTO (_) values (mysqli_result) ? or do I have to loop through the entire result set? edit: can I insert mysqli_result queries or do I have to do conventional rows Edited September 8, 2014 by ala888 Link to comment Share on other sites More sharing options...
thescientist Posted September 8, 2014 Share Posted September 8, 2014 my suggestion was an architectural one, it's not just use query xzy. You will need to plot it all out, write out the psuedo steps if you need, and then approach one piece at a time. First is the script that can connect to all your databases, gets the results from each one, then inserts into the master database. Getting it to run on a cron would come after that. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now