For example, there is a table in the database:
in php, new data (users) for this table are entered into the array from the file, they need to be added there. But those users who are already in the table, but not in the array - need to be removed from the table, if there is no such user - then add, which are the same - leave.
I do not know what kind of request you need to make. update
or replace
- do not fit as far as I understood. Those. need to somehow combine insert
and delete
? I do not know how to do it.
It’s only up to me to pull all the data from the table into an array, process everything in php
and make the desired final array, then delete all the records from the table and write everything back to the new one ... but is this a bad way?
I don't really understand SQL
. Tell me, please, how to do this?