iainr Posted April 11, 2010 Share Posted April 11, 2010 Hi Guys, Attempting to do something which I'm not sure is possible (at least how I'm currently doing it). I'll try to explain as best I can. I've got several different databases, lets say one stores information about people, one about trees and one about computers. The information in them is pretty unrelated, but each has a field saying when any record was last updated. At the moment I'm extracting a list of all records in 'people' updated after a certain date (then printing them out), all records in 'trees' modified after a certain date (and printing them out), and the same for 'computers'. I want to sort the records by 'date_updated' as well - but if I sort each record set as it is extracted (using ORDER BY) I simply get people, trees and computers all separately printed out but individually sorted by date_updated. What I'd like is a big list of records from all three databases, universally sorted by the 'date_updated' field, so the records could be all muddled up but in the correct order of date_updated. I've attempted to feed the data into arrays but then realised if I sort one array the others wont follow suit and the data wont match any more, Any advice on this is appreciated - also if it doesn't make sense I can try to explain again, Thanks! Link to comment https://forums.phpfreaks.com/topic/198200-extract-data-from-multiple-sources-concatenate-it-together-and-sort-it/ Share on other sites More sharing options...
Chris92 Posted April 11, 2010 Share Posted April 11, 2010 Here are a few function you might want to look at: http://php.net/manual/en/function.array-merge.php http://www.php.net/manual/en/function.array-flip.php I wish you luck. Link to comment https://forums.phpfreaks.com/topic/198200-extract-data-from-multiple-sources-concatenate-it-together-and-sort-it/#findComment-1039908 Share on other sites More sharing options...
iainr Posted April 13, 2010 Author Share Posted April 13, 2010 Thanks for your reply I managed to get it working using a multi-dimensional array combined with a custom sorting function! Job done!! Link to comment https://forums.phpfreaks.com/topic/198200-extract-data-from-multiple-sources-concatenate-it-together-and-sort-it/#findComment-1041114 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.