How in php to organize the storage of the temporary table data to the time of the script?

Writing exchange for a site with an external service. Write on the side of the site to service only requests via its API. Each entity which is exchanged, is:
1) id's on the website (mysite_id)
2) external id on the website (mysite_ext_id)
3) external id in the external service (service_ext_id)
4) id on the external service. (service_id)
During script execution I need to quickly record matching one of the values of others, then to use.
The data structure is like a table whose columns (4 id) is gradually filled during the run. And for each row I need to be able to obtain value service_ext_id corresponding mysite_id at service_ext_id corresponding service_id, etc.

I don't know how better to organize the storage of such information. Now all this is written in a bunch of associative arrays like [service_ext_id1 => mysite_id1, service_ext_id2 => mysite_id2, ...]. And there are plenty of methods to access the the old type getServiceIdByMysiteId, getServiceIdByServiceExtId, getMysiteIdByServiceExtId etc.

In a separate table in the database seems not necessary, because the information exists and is used only while the script is executed, then it will become irrelevant. And queries to this table at run time would be very much.

I want to structure and properly organize the storage in memory and access r information, which is formatted as a table. And then another, and to convey the received information to other methods. As would be more logical just to do it?
April 7th 20 at 11:08
3 answers
April 7th 20 at 11:10
Solution
I want to structure and properly organize the storage in memory

Well, actually, here and contains the answer to the question.
All sorts of key-value value does not fit us, but a rectangular table - very even.
Given that relational databases allow sahawat table in memory, problem solved. Mysql will be here too, but sqlite is fine
$db = new PDO('sqlite::memory:');
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$db->query("CREATE TABLE temp (mysite_id int,int mysite_ext_id,service_ext_id int,service_id int)");

well, then regular requests
$db->query("INSERT into temp (mysite_id) values (1)");
var_dump($db->query("SELECT service_ext_id FROM temp where mysite_id=1")->fetchColumn());
April 7th 20 at 11:12
Solution
Well, you can use SQLite for your purposes. You will have full database and the necessary tables that you can index the required columns if necessary.
And at the end of all operations simply delete the database file and all)
hint: sqlite::memory - Lisette.Botsford54 commented on April 7th 20 at 11:15
April 7th 20 at 11:14
Solution
if you need to be worked out during the processing of the script, in the database there is no need, it will only increase the load and therefore the processing time.
in this case, it is best to store in array or in object.
if the elements are connected, it is not difficult to write a script, for example, to merge into a multidimensional array.
Why? - Lisette.Botsford54 commented on April 7th 20 at 11:17

Find more questions by tags PHPData structuresRefactoring