suppose have sort of forum topics users/admins can visit/manage.
when user visit it, first i'll check if topic exist; after put flag system if user has been visited topic.
this basic code :
1 if((isset($_get['trackid'])) && (ctype_digit($_get['trackid']))) { 2 $query=mysql_query("select date, user, zone, artist, event, data, res, complete, notes topic trackid='".$_get['trackid']."'",$mydb); 3 if(mysql_num_rows($query)!=0) { 4 echo "ok, topic exist! can system have visited topic" 5 6 if (isset($_session['nickname'])) $insert=mysql_query("insert ignore recent_adds (user, trackid) values ('".$_session['nickname']."','".$_get['trackid']."')",$mydb); 7 } 8 }
now, suppose user a
arrive line 4, , meanwhile admin (user b
) remove topic (trought special function admins, doesn't mean much) : insert inconsistent data database. (in fact topic won't exist anymore).
how major forum/system kind of operation rid concurrency problem?
you can use foreign keys disallow inserting have been deleted. benefit of doing cascading delete.
another solution run batch job cleans out inconsistent data. along lines of solution, not delete topic. mark deleted status flag , delete later.
Comments
Post a Comment