用戶發送sql查詢,有時(通常是服務器繁忙)sql行重複。我想阻止它。示例如果用戶同時發送相同的查詢,sql只接受一個查詢。我不想刪除它總是..我可以做到這一點在phpmyadmin?SQL防止重複輸入
如果我不能,問題在這個PHP: http://www.speedyshare.com/S4QRj/Automation.php
我想在這個代碼:
private function returnunitsComplete() {
global $database;
$time = time();
$q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."attacks where ".TB_PREFIX."movement.ref = ".TB_PREFIX."attacks.id and ".TB_PREFIX."movement.proc = '0' and ".TB_PREFIX."movement.sort_type = '4' and endtime < $time";
$dataarray = $database->query_return($q);
foreach($dataarray as $data) {
$tribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0);
if($tribe == 1){ $u = ""; } elseif($tribe == 2){ $u = "1"; } elseif($tribe == 3){ $u = "2"; } elseif($tribe == 4){ $u = "3"; } else{ $u = "4"; }
$database->modifyUnit(
$data['to'],
array($u."1",$u."2",$u."3",$u."4",$u."5",$u."6",$u."7",$u."8",$u."9",$tribe."0","hero"),
array($data['t1'],$data['t2'],$data['t3'],$data['t4'],$data['t5'],$data['t6'],$data['t7'],$data['t8'],$data['t9'],$data['t10'],$data['t11']),
array(1,1,1,1,1,1,1,1,1,1,1)
);
$database->setMovementProc($data['moveid']);
}
有時返回複製單位和報告。對不起,我的英語不好。謝謝...
你看過'UNIQUE'列索引嗎? – deceze
當你說查詢意味着要插入數據庫的數據庫或數據的問題? – HMarioD