wangcnc2005
中级会员
 
UID 79276
精华
0
积分 311
帖子 219
金钱 311 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2006-8-30
状态 离线
|
[广告]: q
m
数据库缓存
<? $n=0; while($n<5) { $url="xxx.htm"; $data=parsedata($url); $addtime=time(); $url=""; $sql="insert into xxxx set n='$n'"; echo $sql."<br>"; //此处输出$sql不重复 mysql_query($sql); $csql="insert into yyy...."; mysql_query($csql); $n++; }
function parsedata($url) { ob_start(); readfile($url); $contentdata= ob_get_contents(); ob_end_clean(); return $contentdata; } ?>
<? 结果: //--------------------------------------- 页面显示结果 insert into xxxx set n='0' insert into xxxx set n='1' insert into xxxx set n='2' insert into xxxx set n='3' insert into xxxx set n='4' 循环5次,出现5条.
数据库结果. 程序改动一下.数据库插入正常,插入5条 insert into xxxx set n='0' insert into xxxx set n='1' insert into xxxx set n='2' insert into xxxx set n='3' insert into xxxx set n='4'
//------------------------------------ 程序不改动的情况下大于2次执行. 页面显示结果正常. insert into xxxx set n='0' insert into xxxx set n='1' insert into xxxx set n='2' insert into xxxx set n='3' insert into xxxx set n='4' 循环5次,出现5条.
但是数据库结果有时候正常,有时候不正常. 会出现重复现象. //第1种异常 insert into xxxx set n='0' insert into xxxx set n='0' insert into xxxx set n='1' insert into xxxx set n='1' insert into xxxx set n='2' insert into xxxx set n='2' insert into xxxx set n='3' insert into xxxx set n='3' insert into xxxx set n='4' insert into xxxx set n='4'
//第2种异常,交替重复 insert into xxxx set n='0' insert into xxxx set n='1' insert into xxxx set n='0' insert into xxxx set n='1' insert into xxxx set n='2' insert into xxxx set n='3' insert into xxxx set n='2' insert into xxxx set n='3' insert into xxxx set n='4' insert into xxxx set n='4'
//第3种正常 insert into xxxx set n='0' insert into xxxx set n='1' insert into xxxx set n='2' insert into xxxx set n='3' insert into xxxx set n='4'
//===========================================================
1.应用了这些函数造成的. ob_start(); readfile($url); $contentdata= ob_get_contents(); ob_end_clean();
我试了一下,应用ob_flush(),ob_end_flush() ,flush(),解决不了问题.
2.我认为是数据库结果缓存造成的.这个如何清除缓存? FLUSH flush_option [,flush_option]? 哪个参数能解决上述问题,并且效率高的?
3.还是其他原因?
?>
|  ASP/PHP/JSP/WAP. |
|