Files
html/api/_tmp_find_contacts.php
OpusWIRE fb41795eb4
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
V94 END auto agent sync
2026-04-20 14:24:51 +02:00

26 lines
886 B
PHP

<?php
$c = pg_connect("host=127.0.0.1 port=5432 dbname=adx_system user=admin password=admin123");
// Find all contacts-like tables
$r = pg_query($c, "SELECT table_schema, table_name FROM information_schema.tables WHERE table_name ILIKE '%contact%' ORDER BY 1,2");
echo "Contact tables:\n";
$tables = [];
while($row = pg_fetch_row($r)) {
$tables[] = "$row[0].$row[1]";
echo " $row[0].$row[1]\n";
}
echo "\nRow counts:\n";
foreach ($tables as $t) {
$r = @pg_query($c, "SELECT COUNT(*) FROM $t");
if ($r) {
$n = pg_fetch_row($r)[0];
echo " $t = $n\n";
}
}
// Find which table has 'orphans_contacts' ref in code or KPI
$r = pg_query($c, "SELECT table_schema, table_name FROM information_schema.columns WHERE column_name = 'company_id' LIMIT 10");
echo "\nTables with company_id column:\n";
while($row = pg_fetch_row($r)) echo " $row[0].$row[1]\n";