. 1 <? PHP 2 $ ID =. 1 ; . 3 $ PDO = new new the PDO ( "MySQL: Host = 127.0.0.1; dbname = Test", "the root", "the root" ); . 4 $ PDO -> Exec ( "the UPDATE` = `` nums` the SET ms_goods`-nums`. 1 the WHERE ID = $ ID " ); . 5 echo " Miao SHA Success " ; . 6 // queue link list List: Array . 7 // Array: last out . 8 // List: advanced first-out 9 ?>
. 1 <? PHP 2 // Stock complex: sufficient amount of concurrency . 3 $ R & lt = new new the Redis (); . 4 . 5 $ R & lt -> Connect ( "127.0.0.1", 6379 ); . 6 . 7 $ RES = $ R & lt -> RPOP ( "mslist"); // right Right: dequeuing ---> . 8 . 9 IF (! $ RES ) { 10 echo "oUT of Print" ; . 11 } the else { 12 is $ ID =. 1 ; 13 is $ PDO = new newThe PDO ( "MySQL: Host = 127.0.0.1; dbname = Test", "the root", "the root" ); 14 $ PDO -> Exec ( "the SET ms_goods` the UPDATE` `` nums` = nums` the WHERE-ID. 1 = ID $ " ); 15 echo " Miao SHA Success " ; 16 } . 17 18 is // queue link list List: Array . 19 // Array: last-out 20 is // List: FIFO 21 >?
1 ? < PHP 2 $ the above mentioned id = 1; // event the above mentioned id 3 $ PDO = new new PDO ( "MySQL: Host = 127.0.0.1; dbname = the Test", "root", "root" ); 4 $ NUM = $ PDO -> Query ( "the SELECT *` the FROM ms_goods` the WHERE ID = $ ID ") -> FETCH (); . 5 $ the nums = $ NUM [ 'the nums']; // Stock . 6 . 7 @ stock complex: sufficient amount of concurrency . 8 $ R & lt = new new the Redis (); . 9 10 $ R & lt -> Connect ( "127.0.0.1", 6379 ); 11 12 for($i=1;$i<=$nums;$i++){ 13 $r->lpush("mslist","$i"); //left 左:入队 ----> 14 } 15 16 echo "[nums:{$nums}] list: miaosha start ..."; 17 ?>
1 <?php 2 $id = 1; 3 $pdo=new PDO("mysql:host=127.0.0.1;dbname=test","root","root"); 4 $res=$pdo->query("SELECT * FROM `ms_goods` where id = $id")->fetch(PDO::FETCH_ASSOC); 5 ?> 6 7 <!DOCTYPE html> 8 <html lang="en"> 9 <head> 10 <meta charset="UTF-8"> 11 <title>秒杀功能</title> 12 </head> 13 <body> 14 15 <center> 16 <h1 of> buying activities, selling, marketing </ h1 of> . 17 <div style = "width: 320px; height: 160px; border: 1px Solid #ccc;"> 18 is <IMG the src = "tel_5.jpg" /> . 19 </ div> 20 is <P> Stock: <PHP? echo $ RES [ 'the nums'];?> </ P> 21 is <Button ID = "msbtn"> spike </ Button> 22 is </ Center> 23 is 24 < / body> 25 </ HTML> 26 is 27 <Script type = "text / JavaScript"> 28 document.getElementById ( 'msbtn').onclick=function(){ 29 window.location.href = 'doms.php'; 30 } 31 </script>