S
S
smash_wp2016-11-01 20:18:35
PHP
smash_wp, 2016-11-01 20:18:35

How to parse data and write it to the database?

The data is parsed, I know how to write it to the database. The question is this. The data will be parsed from time to time. That is, there will be new records, there will also be records that are already in the database, but their information in some separate column has changed.
So how can I implement/check correctly, is this a new record and just add it to the table, or is this record (by id) already in the database and just update its data?
I will be very grateful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2016-11-01
@smash_wp

You are looking for a unique value (field) that all records have. You compare against it. If there is a record in the database with such a value in this field, we update it, if not, we create it. In the database, you can even forcibly make this field unique, which would swear at duplicates.
Z.Y. It would not be bad to indicate both the database and the type of data (at least where they come from), for a normal answer, and not guessing thoughts ..

E
entermix, 2016-11-01
@entermix

The data is parsed, I know how to write it to the database.

And to receive a line on ID and to check up before record? What is the problem?
PS You can make a field idunique in the table and do INSERT ... ON DUPLICATE KEY UPDATE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question