I'm just a beginner with programming
I want to know if anyone have solution for my problem (PostgreSQL & Yii2)
I have one button to submit these array data (for this case just 5 rows):
+----+--------+
| id | name |
+----+--------+
| 1 | apple |
| 2 | orange |
| 3 | manggo |
| 1 | fish |
| 4 | meat |
+----+--------+
- if id=1 not exist, insert record1 ( or to temp tbl )
- if id=2 not exist, insert record2 ( or to temp tbl )
- if id=3 not exist, insert record3 ( or to temp tbl )
- if id=1 not exist, insert record2 ( this one failed, cancel all 1,2,3 and stop )
Every step using 2 queries (SELECT COUNT & INSERT)
+----+--------+
| id | name |
+----+--------+
| 1 | apple |
| 2 | orange |
| 3 | manggo |
| 4 | fish |
| 5 | meat |
+----+--------+
For second case after all proceed (until id=5 no record exist) commit to database
Thank you