PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC] ); echo "=== 1) Do the three columns exist? ===\n"; $cols = $pdo->query("SHOW COLUMNS FROM tt_content LIKE 'tx_vitec_bg_%'")->fetchAll(); if ($cols === []) { echo " NONE. database:updateschema has not created them.\n"; } else { foreach ($cols as $c) { echo sprintf(" %-24s %-18s default=%s\n", $c['Field'], $c['Type'], var_export($c['Default'], true)); } } echo "\n=== 2) The record itself (uid $uid) ===\n"; // Column list built from section 1 rather than hard-coded, so every tx_vitec_bg_* // field added later shows up here without the script needing an edit. $select = array_merge( ['uid', 'pid', 'CType', 'deleted', 'hidden', 'sys_language_uid', 'l18n_parent'], array_column($cols, 'Field') ); $row = $pdo->query('SELECT ' . implode(', ', $select) . " FROM tt_content WHERE uid = $uid")->fetch(); if (!$row) { echo " no tt_content row with uid $uid\n"; } else { foreach ($row as $k => $v) { echo sprintf(" %-24s %s\n", $k, var_export($v, true)); } } echo "\n=== 3) File references pointing at this record ===\n"; $refs = $pdo->query( "SELECT r.uid, r.tablenames, r.fieldname, r.uid_local, r.uid_foreign, r.deleted, r.hidden, r.sorting_foreign, f.identifier, f.name, f.mime_type FROM sys_file_reference r LEFT JOIN sys_file f ON f.uid = r.uid_local WHERE r.uid_foreign = $uid AND r.tablenames = 'tt_content'" )->fetchAll(); if ($refs === []) { echo " NONE - nothing references this record. The image was not saved.\n"; } else { foreach ($refs as $r) { echo sprintf(" ref %-6s field=%-22s file=%s deleted=%s hidden=%s\n", $r['uid'], $r['fieldname'], (string)$r['identifier'], $r['deleted'], $r['hidden']); } } echo "\n=== 4) Which fieldnames does tt_content use at all? (top 15) ===\n"; foreach ($pdo->query("SELECT fieldname, COUNT(*) c FROM sys_file_reference WHERE tablenames='tt_content' AND deleted=0 GROUP BY fieldname ORDER BY c DESC LIMIT 15")->fetchAll() as $r) { echo sprintf(" %-28s %d\n", $r['fieldname'], $r['c']); }