当前位置 : 主页 > 网络编程 > PHP >

insert_mysql_10000_data.php

来源:互联网 收集:自由互联 发布时间:2021-06-28
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
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_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;
    }
上一篇:funbase-hayden.php
下一篇:microtime.php
网友评论