Ecshop seconds when the inventory is reduced to less than 0 after the inventory is updated, the inventory is checked, and if the inventory is negative, the rollback of the transaction is performed.
Begin ();//Start a thing processing start$sql= "UPDATE".$GLOBALS[' A ']->table (' Seconds_kill '). " SET Kill_stock = kill_stock-1 WHERE sk_id= ' ".$sk _id."‘ LIMIT 1 " ;$GLOBALS[' DB ']->query ($sql);$sql= "Select Kill_stock". "From".$GLOBALS[' A ']->table (' Seconds_kill '). "WHERE sk_id= '".$sk _id."‘";$kucun=$GLOBALS[' DB ']->getone ($sql);if($kucun<0) {rollback (); Show_message (' I'm sorry, but your purchase is out of stock! ', ' return ', ' ', ' error '); die();}Else{commit ();}//Startfunctionbegin () {$GLOBALS[' DB '], query ("Set autocommit=0");//set up auto-commit $GLOBALS[' DB '], query ("Begin");//Transaction Start}//Submitfunctioncommit () {$GLOBALS[' DB '], query ("commit");//Submit $GLOBALS[' DB '], query ("Set Autocommit=1");}//rolling backfunctionrollback () {$GLOBALS[' DB '], query ("rollback");//Rollback of database changes made $GLOBALS[' DB '], query ("Set Autocommit=1");}
Ecshop seconds to kill the inventory will be reduced to less than 0 of the solution