PHP框架 Laravel Eloquent ORM 批量插入数据,怎么实现
1个回答
展开全部
不是laravel的,,试试吧
ini_set('max_execution_time','0');
$pdo = new PDO("mysql:host=localhost;dbname=test","root","123456");
$sql = "insert into test(id,account_id,name,created_time,status) values";
for($i=0; $i<100000; $i++){
$str = strrand(32);
$sql .="('".$str."','assdasa','zhangsan','2015-09-17 07:55:10','active'),";
}
$sql = substr($sql,0,strlen($sql)-1);
var_dump($sql);
if($pdo -> exec($sql)){
echo "插入成功!";
echo $pdo -> lastinsertid();
}
ini_set('max_execution_time','0');
$pdo = new PDO("mysql:host=localhost;dbname=test","root","123456");
$sql = "insert into test(id,account_id,name,created_time,status) values";
for($i=0; $i<100000; $i++){
$str = strrand(32);
$sql .="('".$str."','assdasa','zhangsan','2015-09-17 07:55:10','active'),";
}
$sql = substr($sql,0,strlen($sql)-1);
var_dump($sql);
if($pdo -> exec($sql)){
echo "插入成功!";
echo $pdo -> lastinsertid();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询