fixGroupMemberNum.php 641 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * 修复群人数
  4. * User: solu
  5. * Date: 2019/2/27
  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. $objGroup = new GroupInfo();
  13. $objUserGroup = new UserGroup();
  14. $groups = $objUserGroup->objTable->getAll([
  15. '_field' => 'group_id, count(user_id) as c',
  16. '_groupby' => 'group_id',
  17. ]);
  18. foreach ($groups as $g) {
  19. $objGroup->objTable->updateObject(['member_num' => $g['c']], ['group_id' => $g['group_id']]);
  20. }
  21. $c = count($groups);
  22. $t = microtime(true) - $st;
  23. var_dump("处理{$c},耗时{$t}");