标签:style blog class code c java
1 <?php 2 3 $serverName = "localhost"; //数据库服务器地址 4 5 $uid = "sa"; //数据库用户名 6 7 $pwd = "hwwlovejsy1314"; //数据库密码 8 9 $connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>"LocationAnalysisDatabase"); 10 11 $conn = sqlsrv_connect( $serverName, $connectionInfo); 12 13 if( $conn == false){ 14 15 echo "连接失败!"; 16 17 die( print_r( sqlsrv_errors(), true)); } 18 19 //执行有结果集的SQL语句 20 21 $query = sqlsrv_query($conn, "select * from user_timeline_new"); 22 23 $count = 1;//用count变量来控制每次更改的数量 24 25 while($row = sqlsrv_fetch_array($query)) 26 27 { 28 29 if($count<=274245) 30 31 { sqlsrv_query($conn,"update user_timeline_new set time = ‘".strtotime($row[‘time‘])."‘ where uid = ‘".$row[‘uid‘]."‘ and time = ‘".$row[‘time‘]."‘"); 32 33 $count++; 34 35 }else{ break; } 36 37 } ?> 38
这个程序主要问题是运行的时间过长,往往会遇到:Maximum execution time of 30 seconds
exceeded的问题,这个只要修改PHP.INI中max_execution_time
将后面的值调大,然后重新启动APACHE服务,就OK了。
刚开始用的是sqlsrv直接修改SqlServer2008中表,效率过低,然后试着用MySQL数据库,发现效率一样低。白忙活半天。
php中将数据库中time由String改为时间戳,布布扣,bubuko.com
标签:style blog class code c java
原文地址:http://www.cnblogs.com/hewenwu/p/3729407.html