/** * Returns db-type of given $column name as a string. */ function getColumnType($db, $table, $column) { $column = strtolower($column); $columns = describeTable($db, $table); foreach ($columns as $col) { if (strtolower($col->name) == $column) { return strtolower($col->type); } } }
function showTables($db_in) { $db = $db_in; try { $tables = "<table class=\"table table-striped table-hover \"><tbody><thead><tr><th>Tables</th></tr></thead>"; $sql = "SHOW TABLES"; $st = $db->prepare($sql); $st->execute(); while ($iterate = $st->fetch(PDO::FETCH_NUM)) { $details = describeTable($db, $iterate[0]); $tables .= "<tr data-html=\"true\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"\" data-original-title=\"" . $details . "\"><td>" . $iterate[0] . "</td></tr>"; } $tables .= "</tbody></table>"; return $tables; } catch (PDOException $e) { echo "showTables error: " . $e->getMessage(); //file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); } }