PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Jul 04, 2020 2:12 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Jun 02, 2008 6:02 pm 
Offline
Forum Newbie

Joined: Mon Jun 02, 2008 5:42 pm
Posts: 2
Hi,

I have data horizontally partitioned over several MySQL servers. After I connect and run a query on each server, I'd like to merge the results they give me and use that data in a loop to fill a table with data, reverse sorted by a PRIMARY KEY. I presume this would be done with arrays.

I'm still quite new to PHP and I'd like some help solving this problem.

Thank you.


Top
 Profile  
 
PostPosted: Mon Jun 02, 2008 6:04 pm 
Offline
Site Administrator
User avatar

Joined: Sun May 19, 2002 10:24 pm
Posts: 6887

_________________
Image


Top
 Profile  
 
PostPosted: Mon Jun 02, 2008 6:53 pm 
Offline
DevNet Master
User avatar

Joined: Fri Jan 18, 2008 1:36 am
Posts: 3549
Location: Israel, ME
You might be better off performing a UNION to combine all the different datasets into one at the database level. You can then apply ordering and grouping clauses on the entire dataset.


Top
 Profile  
 
PostPosted: Mon Jun 02, 2008 7:00 pm 
Offline
Forum Newbie

Joined: Mon Jun 02, 2008 5:42 pm
Posts: 2


Top
 Profile  
 
PostPosted: Mon Jun 02, 2008 7:53 pm 
Offline
Site Administrator
User avatar

Joined: Sun May 19, 2002 10:24 pm
Posts: 6887
I recommended array_merge assuming you already have all 3 complete result sets stored in arrays. You can use $record = array_shift($array); to pull a record off the array stack or you can loop through them with foreach(). Have a look at the array functions for details. Without knowing more that's about all I can tell you.

http://us2.php.net/manual/en/ref.array.php

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group