#!/usr/bin/perl
###################################
### author: www.jb51.net ###
### QQ群:232608061 ###
### E-mail:service@jb51.net ###
###################################
use DBI;
my $driver=”DBI:mysql”;
my $from_database=”ttlsa”;
my $from_user=”root”;
my $from_password=”123456″;
my $from_host=”localhost”;
$from_dbh=DBI->connect (“$driver:$from_database:$from_host;user=$from_user;password=$from_password”) or die “cannot connect: “. DBI->errstr;
$from_dbh->do(“set names ‘utf8′”);
$from_dbh->do(“set session autocommit=0″);
$from_dbh->do(“set session unique_checks=0″);
$max=600000;
$step=10000;
for ($i=1;$i $step_i=$i+$step;
$sql=”select * from ttlsa_users where user_id>=$i and user_id $sth=$from_dbh->prepare($sql);
$sth->execute;
@value=();
while ($row=$sth->fetchrow_hashref()) {
$uid=$row->{uid};
$email=$row->{email};
$passwd=$row->{passwd};
$user_name=$row->{user_name};
$key=substr($user_id,-1);
$value[$key].=”(‘$uid’,’$email’,’$passwd’,’$user_name’),”;
}
for (0..9) {
chop($value[$_]);
$sql=”insert into ttlsa_user_$_ (`uid`,`email`,`passwd`,`user_name`) values” . $value[$_];
$from_dbh->do(“$sql”);
}
}
$from_dbh->do(“set session autocommit=1″);
$from_dbh->do(“set session unique_checks=1″);
$sth->finish();
$from_dbh->disconnect();