thinkphp 多数据插入

 

public function _initialize(){
  $this->m = M('Abc');
}

public function add2(){
  $sql= "insert into ysn_abc (value) values";
  set_time_limit(0);
  echo date('H:i:s');
  for($i=0;$i<10000;$i++){
  $sql.="('50'),";
};
  $sql = trim($sql,',');
  $abc = new \Think\Model();
  $abc->execute($sql);
  echo '<br>';
  echo date('H:i:s');
}


public function add3(){
  set_time_limit(0);
  echo date('H:i:s');
  $arr = array();
  for($i=0;$i<10000;$i++){
    $arr[]=50;
  };

  $this->m->addAll($arr);
  echo '<br>';
  echo date('H:i:s');
}

 

posted on 2017-07-14 16:46  炊厨  阅读(202)  评论(0)    收藏  举报

导航