Synchronizing set with SQL table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Technical
Forum Commoner
Posts: 81
Joined: Thu Dec 02, 2010 5:30 am

Synchronizing set with SQL table

Post by Technical »

Hello there. I have an array which I need to synchronize with SQL table.
The table has two columns - id and text. I need to remove old values from the table and insert new. Don't need updating.

My current sequence:
1) Remove rows which aren't present in the current array
2) Get current table records
3) Go through current records and insert new values

Other way is more simple:
1) Remove all rows
2) Insert array items

Which one is more efficient? Or there is better way?
User avatar
Technical
Forum Commoner
Posts: 81
Joined: Thu Dec 02, 2010 5:30 am

Re: Synchronizing set with SQL table

Post by Technical »

Any suggestions?
Post Reply