<?php $start = microtime(); $arr = array(); for ($i = 0; $i < 1000; $i++) { array_push($arr, Array ( 'userid' => 'feng003', 'status' => 3, 'confirm_time' => 1427940803, 'pv_total' => 0.00 ) ); } $sql = 'INSERT INTO test (`userid`,`status`,`confirm_time`,`pv_total`) VALUES'; foreach($arr as $k => $item) { $sql .= '("' . $item['userid'] . '",' . $item['status'] . ',' . $item['confirm_time'] . ',' . $item['pv_total'] . '),'; } $sql = rtrim($sql, ','); $conn=mysql_connect('localhost', 'lee', '111111') or die("error connecting") ; //连接数据库 mysql_query("set names 'utf8'"); //数据库输出编码 应该与你的数据库编码保持一致.南昌网站建设公司百恒网络PHP工程师建议用UTF-8 国际标准编码. mysql_select_db('test'); //打开数据库 $result = mysql_query($sql,$conn); //查询 echo microtime() - $start; /* SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `test` -- ---------------------------- DROP TABLE IF EXISTS `test`; CREATE TABLE `test` ( `u_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `userid` int(11) NOT NULL, `status` varchar(255) NOT NULL, `confirm_time` int(10) NOT NULL, `pv_total` decimal(10,2) NOT NULL, `name5` varchar(255) NOT NULL, PRIMARY KEY (`u_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; */

分类: web

标签: