Example #1
0
 /**
  * 注册用户账号转化
  */
 private function convertUsers()
 {
     $tableMigrate = new TableMigrate();
     // 清空数据
     $dstTable = new DstDataMapper('users');
     $tableMigrate->clearTable($dstTable);
     $tableMigrate->clearTable(new DstDataMapper('user_account'));
     $tableMigrate->clearTable(new DstDataMapper('user_address'));
     $tableMigrate->clearTable(new DstDataMapper('user_bonus'));
     $tableMigrate->clearTable(new DstDataMapper('user_feed'));
     $tableMigrate->clearTable(new DstDataMapper('user_rank'));
     //转化数据
     $tableMigrate->convertTable('user', array(), array('order' => 'id asc'), 'users', array('id' => 'user_id', 'email' => 'email', 'username' => 'user_name', 'password' => 'password', 'money' => 'user_money', 'sns' => 'sns_login', 'login_time' => 'last_login', 'create_time' => 'reg_time', 'score' => 'ec_salt'), array('login_time' => function ($login_time, $record) {
         //抓换成 GMT 时间
         return Time::localTimeToGmTime($login_time);
     }, 'create_time' => function ($create_time, $record) {
         //抓换成 GMT 时间
         return Time::localTimeToGmTime($create_time);
     }, 'score' => function ($score, $record) {
         return '@4!@#$%@';
         // 注意:这里是最土系统里面写死的值
     }));
     // 重设表的 AUTO_INCREMENT 值
     $tableMigrate->resetAutoIncValue($dstTable, 'user_id');
     // 清理数据
     unset($tableMigrate);
     unset($dstTable);
     unset($result);
 }