initFirstAccount.php 937 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * 首次登录账号初始化
  4. * User: solu
  5. * Date: 2019/4/04
  6. */
  7. ini_set("display_errors", "On");
  8. set_time_limit(0);
  9. error_reporting(E_ALL & ~E_NOTICE);
  10. require_once realpath(dirname(__FILE__)) . '/../common.php';
  11. $st = microtime(true);
  12. // UPDATE user_info u, user_bind_info b set u.first_account=b.account WHERE u.user_id=b.user_id and u.first_type=b.type
  13. exit(); // sql更新,脚本废弃
  14. $objUser = new TableHelper('user_info', 'dw_chat');
  15. $objUserBind = new UserBindInfo();
  16. $c = 0;
  17. $users = $objUser->getDb()->getAll("select user_id, first_type from `user_info` where isnull(first_account)");
  18. foreach ($users as $user) {
  19. $account = $objUserBind->getAccountByUserId($user['user_id'], $user['first_type']);
  20. if ($account) {
  21. $objUser->updateObject(['first_account' => $account], ['user_id' => $user['user_id']]);
  22. $c += 1;
  23. }
  24. }
  25. $t = microtime(true) - $st;
  26. var_dump("处理{$c},耗时{$t}");