Programming with PHP and MySql
The $data array contains id (unique), date.
Insert this data into the MySQL table
If MySQL already has the same date, you want to exclude that $data and insert the data into MySQL.
Please let me know if there is a simple way to compare the array with the MySQL table data.
php mysql sql
You can create and update with the first key at the same time.
INSERT INTO table(a,b,c)VALUES(1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
https://dev.mysql.com/doc/refman/5.6/ja/insert-on-duplicate.html
If it already exists, you can update the update item with a date, etc., or overwrite the existing data.If there is no data update, it is also fast because it does not actually run.
I think it's easiest to select data and then compare it.
select date from table_name;
I will insert it after I get it as an array.
If you use insert into ... duplicate key update, it is easier to update the data by setting the update target to an update date or something like that.
578 Understanding How to Configure Google API Key
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.