- 最佳化 for 迴圈
- 把DOM節點附加至文件
- 減少點 (dot) 標記
Reference
Ajax in Action
$data = "魚乾的筆記本"; $key = "fishjerk"; $sig = md5($data, true); // = hash('md5', $data); //Output 32個字元特徵碼: 9fc745260dedf115ec7b62fa811f0698 $sig = hash_hmac('sha256', $data, $key ); //跟hash('sha256')的差別是多了$salt改變特徵碼 //Output 64個字元特徵碼: 7b8ddbde1cc031945d23d82af786a83048e40efff7c1194ed9ea6c6f0fae39b2 $sig = hash_hmac('sha512', $data, $key ); //Output 128個字元特徵碼: 8cb44d44e52b443fa3095a06668dd6e31b8ce973f3b4f353d40ca35b47605dc41ff3ab003f375aee5ed1a14456e2b783d1f98543cc111822ea63d26d1427ea61
啥系 Select For Update
就是把某欄位select 出來做 update
//例如.. SELECT quantity FROM products WHERE id=1 ...拉出來減掉購買數... 再更新回DB Update products Set quantity = $quantity WHERE id =1
看起來沒問題,但如果在select後,update前,這商品先其他人更新了,這quantity就會有問題了~
所以Oracle可以下
這樣會把此筆先lock,其他人就select此商品就待等待Update剛成SELECT quantity FROM products WHERE id=1 FOR UPDATE
SELECT quantity FROM products WHERE id = 1 WITH (UPDLOCK) ... UPDATE FROM products SET quantity = $quantity WHERE id =1
SELECT * quantity FROM products WHERE id=1 FOR UPDATE NOWAIT; //不等,回報錯誤 SELECT * quantity FROM products WHERE id=1 FOR UPDATE NOWAIT skip Locked; //不等,給目前的值 也就是dirty read
SELECT * quantity FROM products WHERE id=1 WITH (NOWAIT); //不等,回報錯誤 SELECT * quantity FROM products WHERE id=1 WITH (NOLOCK); //不等,給目前的值 也就是dirty read