clqms-be/check_db.php

19 lines
742 B
PHP
Raw Normal View History

<?php
// Simple DB check script
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
require 'vendor/codeigniter4/framework/system/Test/bootstrap.php';
$db = \Config\Database::connect();
$tables = ['location', 'site', 'account', 'patient', 'patvisit', 'valueset', 'contact'];
foreach ($tables as $table) {
try {
$count = $db->table($table)->countAllResults();
echo "$table count: $count\n";
if ($count > 0) {
$row = $db->table($table)->get(1)->getRow();
echo "$table first row ID: " . (isset($row->{$table.'ID'}) ? $row->{$table.'ID'} : 'unknown') . "\n";
}
} catch (\Exception $e) {
echo "$table error: " . $e->getMessage() . "\n";
}
}