PHP 7.0.19 和 7.1.5 正式发布了。PHP(PHP:Hypertext Preprocessor)是一种在电脑上执行的 脚本语言 ,主要是用途在于处理动态网页,也包含了命令列执行接口(command line interface),或者产生图形使用者接口( GUI )程式。改进日志如下:
PHP 7.1.5
– Core:
-
. Fixed bug #74408 (Endless loop bypassing execution time limit). (Laruence)
-
. Fixed bug #74353 (Segfault when killing within bash script trap code).(Laruence)
-
. Fixed bug #74340 (Magic function __get has different behavior in php 7.1.x).(Nikita)
-
. Fixed bug #74188 (Null coalescing operator fails for undeclared static class properties). (tpunt)
-
. Fixed bug #74444 (multiple catch freezes in some cases). (David Matějka)
-
. Fixed bug #74410 (stream_select() is broken on Windows Nanoserver).(Matt Ficken)
-
. Fixed bug #74337 (php-cgi.exe crash on facebook callback).(Anton Serbulov)
– Date:
-
. Fixed bug #74404 (Wrong reflection on DateTimeZone::getTransitions).(krakjoe)
-
. Fixed bug #74080 (add constant for RFC7231 format datetime). (duncan3dc)
第一种方法: 使用insert into 插入,代码如下:
1234567 | $params = array (‘value '=>' 50′); set_time_limit(0); echo date (“H:i:s”); for ( $i =0; $i <2000000; $i ++){ $connect_ MYSQL ->insert( $params ); }; echo date (“H:i:s”); |
最后显示为:23:25:05 01:32:05 也就是花了2个小时多!
第二种方法: 使用事务提交,批量插入数据库(每隔10W条提交下)最后显示消耗的时间为:22:56:13 23:04:00 ,一共8分13秒 ,代码如下:
123456789101112 | echo date (“H:i:s”); $connect_mysql ->query(‘BEGIN'); $params = array (‘value '=>' 50′); for ( $i =0; $i <2000000; $i ++){ $connect_mysql ->insert( $params ); if ( $i %100000==0){ $connect_mysql ->query(‘COMMIT'); $connect_mysql ->query(‘BEGIN'); } } $connect_my sql ->query(‘COMMIT'); echo date (“H:i:s”); |
- 除此之外,
PHP常用代码
1、连接MYSQL数据库代码
$connec=mysql_connect(” localhost “,”root”,”root”) or die(“不能连接数据库服务器: “.mysql_error());
mysql_select_db(“liuyanben”,$connec) or die (“不能选择数据库: “.mysql_error());
mysql_query(“set names ‘gbk'”);
?>
2、读取数据库,并实现循环输出
$sql=”select * from liuyan order by ly_id desc”;
$conn=mysql_query($sql,$connec);
while($rs=mysql_fetch_array($conn)){
?>
循环的内容………
}
?>
相关文章
本站已关闭游客评论,请登录或者注册后再评论吧~