insert_mysql_10000_data.php public function insert_max() { $res = array(1, 2, 3, ...., 1000000); // $step_length = 5000; $d_name = '达达'; $d_type = 'book'; $d_url = 'www.baidu.com'; $time = time(); $step_total = ceil (count($res) / $step
public function insert_max() { $res = array(1, 2, 3, ...., 1000000); // $step_length = 5000; $d_name = '达达'; $d_type = 'book'; $d_url = 'www.baidu.com'; $time = time(); $step_total = ceil (count($res) / $step_length); $num = 0; for ($i=0; $i < $step_total ; $i++) { $sql = "INSERT INTO fds_download (`b_id`, `b_type`, `d_name`, `d_url`, `create_time`) values"; $start = $i*$step_length; $end = ($i+1)*$step_length; if($end > count($res)) { $end = count($res); } for($j=$start; $j<$end; $j++) { $sql .= " (".$res[$j]. ", '".$d_type."', '".$d_name."', '". $d_url."', ".$time."),"; $num++; } $sql = substr($sql, 0, -1); M()->execute($sql); } echo '成功插入:'.$num; }