count_report.php 618 B

123456789101112131415161718192021222324252627
  1. <?php
  2. require '../../main/inc/global.inc.php';
  3. $eol = "<br />\n";
  4. if (PHP_SAPI == 'cli') {
  5. $eol = "\n";
  6. }
  7. $tables = array(
  8. 'user',
  9. 'course',
  10. 'session',
  11. 'course_rel_user',
  12. 'session_rel_course_rel_user',
  13. 'gradebook_category',
  14. );
  15. echo "$eol--- Post-migration count report ---$eol";
  16. foreach ($tables as $table) {
  17. $sql = "SELECT count(*) FROM $table";
  18. $res = Database::query($sql);
  19. if ($res === false) {
  20. echo "SQL error in ".$sql.$eol;
  21. } else {
  22. $row = Database::fetch_array($res);
  23. $count = $row[0];
  24. echo "Table $table has $count items after migration$eol";
  25. }
  26. }
  27. echo 'The end.'.$eol;