PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_TIMEOUT => 5, ] ); $dbName = 'baronhomep'; $table = 'edu_learning_histories'; $out = []; $out[] = '== TRIGGERS ON edu_learning_histories =='; $stmt = $pdo->prepare( 'SELECT TRIGGER_NAME, EVENT_MANIPULATION, ACTION_TIMING, EVENT_OBJECT_TABLE, ACTION_STATEMENT FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA = ? AND EVENT_OBJECT_TABLE = ? ORDER BY TRIGGER_NAME' ); $stmt->execute([$dbName, $table]); $triggers = $stmt->fetchAll(); if (!$triggers) { $out[] = '(none)'; } else { foreach ($triggers as $t) { $out[] = sprintf('- %s | %s %s ON %s', $t['TRIGGER_NAME'], $t['ACTION_TIMING'], $t['EVENT_MANIPULATION'], $t['EVENT_OBJECT_TABLE']); $out[] = ' ACTION: ' . preg_replace('/\s+/', ' ', (string)$t['ACTION_STATEMENT']); } } $out[] = ''; $out[] = '== ROUTINES REFERENCING edu_learning_histories =='; $stmt2 = $pdo->prepare( 'SELECT ROUTINE_TYPE, ROUTINE_NAME FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = ? AND ROUTINE_DEFINITION LIKE ? ORDER BY ROUTINE_TYPE, ROUTINE_NAME' ); $stmt2->execute([$dbName, '%edu_learning_histories%']); $routines = $stmt2->fetchAll(); if (!$routines) { $out[] = '(none)'; } else { foreach ($routines as $r) { $out[] = sprintf('- %s %s', $r['ROUTINE_TYPE'], $r['ROUTINE_NAME']); } } $out[] = ''; $out[] = '== COLUMNS =='; $stmt3 = $pdo->prepare( 'SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, EXTRA FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? ORDER BY ORDINAL_POSITION' ); $stmt3->execute([$dbName, $table]); $cols = $stmt3->fetchAll(); foreach ($cols as $c) { $out[] = sprintf('- %s | %s | NULL=%s | KEY=%s | EXTRA=%s', $c['COLUMN_NAME'], $c['COLUMN_TYPE'], $c['IS_NULLABLE'], $c['COLUMN_KEY'], $c['EXTRA']); } echo implode(PHP_EOL, $out) . PHP_EOL;