我在php中做更新紀錄的動作
根據print出來的sql語法如下
update `tableS` set `history`='[{"time":"2016-07-14
18:24:22","count":0,"link":"http://aaa.bbb.cc"}]' where account='110101'
只是我的資料表history欄位裡面的資料,卻變成了這樣
[{"time":"2016-07-14
18:24:22","count":0,"link":"http://aaa.bbb.cc"},
{"time":"2016-07-14
18:24:22","count":0,"link":"http://aaa.bbb.cc"},
{"time":"2016-07-14
18:24:22","count":0,"link":"http://aaa.bbb.cc"},
{"time":"2016-07-14
18:24:22","count":0,"link":"http://aaa.bbb.cc"}]
多出了3筆同樣的紀錄
想請問一下各位大大這種狀況是因為什麼呢
程式碼如下,
[code]
$count=0;
$bitStr="1101010101111010";
while($count<30 && strlen($bitStr)>0){
$percent=0.1;
$obj=new stdClass();
$obj->time=$checkDate;
$obj->count=$count*$percent;
$obj->link=$url;
$arr=array();
array_push($arr,$obj);
$str=json_encode($arr);
$sql="update tableS set history='".$str."' where account='".$bitStr."'";
echo $sql;
mysql_query($sql);
$count++;
$bitStr=substr($bitStr,0,-1);
}
[/code]