Pretty much as per the title really – I’ve got a script which is, at the moment, pulling data from MySQL that was initially in MSSQL (another script pulls the information from the MSSQL databaseand populates a holding table in MySQL)
This works fine up to a point, however I’m now getting to the stage where I could really be doing with pulling some information directly from the MSSQL database and some from the MySQL database.
Is there any way of getting PHP to query both MySQL and MSSQL and return the information in a single array?
e.g. if all my information about 10 shops sales for apples is held in MySQL and my information about oranges is held in MSSQL, can I run so that one array shows how many apples and oranges each shop has sold over the last month?
Thanks
Yes, but you won’t get anything for free. You will need to code it yourself. For example:
Then it’s just a matter of going through the array to get your data. There’s multiple ways of structuring your data so you will need to build an array which fits with your needs.
There’s some useful tools in the PHP library for working with arrays. My favorites are array_map, array_filter and usort. Couple this with anonymous functions and you have a strong foundation for building your own filtering and sorting.