php - I'm hitting a race condition in my Laravel application when trying to conditionally INSERT or UPDATE, any suggestions...? -
my users need able upload files site, i've implemented file uploader widget on frontend. allows multiple uploads @ once, , each upload triggers code 1 file @ time save file db. the problem files need stored array in single row in database (i know, know... legacy reasons). in english pseudocode, here's what's happening: laravel sees new file has been uploaded laravel checks whether or not files (at all) have been uploaded entity no files have been uploaded yet? create new record store file. there files entity? update existing record add file array. the problem when multiple files uploaded @ once in quick succession first time, laravel has entered first file in database moments after second file has conducted it's check see if files exist. end duplicate rows, rather updating them in single record. if upload 5 files @ once, typically i'll 4 rows in database - 3 single entries , 1 double-entry, managed catch in time. any practical ways around probl...