php - Update one field multiple times in MySql -
good day all.
i've done script copy csv in database, starts import data in system. done passing multtiple times on whole "import" table, first import categories, take products...and on. each time script passes, update flag field called importato
, when copy csv 0, import categories, put @ 1, 2, , on. in way can keep track of going on.
if encounter error during import, set importato
field 10, @ end have items has got errors. keep track of past imports, every time write csv update importato
11, 12 13 , delete 13. done series of update
:
if(mysql_query("delete `importazione` importato = 13")){ if(mysql_query("delete `importazione` (importato = 4) or (importato = 5) or (importato = 6)")){ if(mysql_query("update importazione set importato = 13 importato = 12")){ if(mysql_query("update importazione set importato = 12 importato = 11")){ mysql_query("update importazione set importato = 11 importato = 10"); } } } }
the problem is... field never updated, stay @ 10
... no error thrown ... problem of buffering in someway? or i'm committing kind of error don't get?
i'm guessing because result of mysql_query
if passed if
statement 1 of them failing means other queries beneath won't run. check user has right permissions able delete from
.
also way doing inefficent. doing in 5 queries in 2
if(mysql_query("delete `importazione` importato = 13 or importato in (4,5,6)") { mysql_query("update importazione set importato = importato + 1 importato in(12,11,10)"); }
please note mysql_
functions deprecated should consider using alternative
Comments
Post a Comment