-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_db.php
45 lines (38 loc) · 1.35 KB
/
test_db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'config/database.php';
try {
$db = new Database();
$conn = $db->conectar();
echo "Conexão com o banco de dados estabelecida com sucesso!\n";
// Testar a tabela de listas
$stmt = $conn->query("SHOW TABLES LIKE 'listas'");
if ($stmt->rowCount() > 0) {
echo "Tabela 'listas' encontrada\n";
// Mostrar estrutura da tabela
$stmt = $conn->query("DESCRIBE listas");
echo "Estrutura da tabela 'listas':\n";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
print_r($row);
}
} else {
echo "Tabela 'listas' não encontrada\n";
}
// Testar a tabela de itens
$stmt = $conn->query("SHOW TABLES LIKE 'itens_lista'");
if ($stmt->rowCount() > 0) {
echo "\nTabela 'itens_lista' encontrada\n";
// Mostrar estrutura da tabela
$stmt = $conn->query("DESCRIBE itens_lista");
echo "Estrutura da tabela 'itens_lista':\n";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
print_r($row);
}
} else {
echo "\nTabela 'itens_lista' não encontrada\n";
}
} catch (PDOException $e) {
echo "Erro na conexão com o banco de dados: " . $e->getMessage() . "\n";
echo "Código do erro: " . $e->getCode() . "\n";
}