LabConker
Gamma
Usuário com poucas negociações! Use sempre o saldo do ForoBeta!
Para aqueles que fazem análise de tabelas em mysql, deixo uma boa ferramenta para que possam consultar os CREATE das tabelas que quiserem.
DEVEM CRIAR ESTAS DUAS TABELAS
CREATE TABLE
CREATE TABLE
NA TABELA cmp_table_catalog coloquem o nome da tabela que querem buscar (coloquem todas as que quiserem).
luego executam este php
<?php
// COLOQUE SUAS CREDENCIAIS AQUI
$host = 'localhost';
$dbname = 'database';
$user = 'root';
$pass = '';
try {
// Criar conexão PDO
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]);
// Obter as tabelas habilitadas
$stmt = $pdo->prepare("SELECT table_name FROM cmp_table_catalog WHERE is_enabled = 'enabled'");
$stmt->execute();
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
if (empty($tables)) {
throw new Exception("Não há tabelas habilitadas em cmp_table_catalog.");
}
// Concatenar o SHOW CREATE TABLE de cada tabela
$fullSql = "";
foreach ($tables as $table) {
$stmt2 = $pdo->query("SHOW CREATE TABLE
$row = $stmt2->fetch(PDO::FETCH_ASSOC);
if (!$row || !isset($row['Create Table'])) {
throw new Exception("Não foi possível obter SHOW CREATE TABLE para a tabela $table");
}
$fullSql .= $row['Create Table'] . ";\n\n";
}
// Salvar o SQL no arquivo tablas_sistema.txt
$filename = DIR . DIRECTORY_SEPARATOR . 'tablas_sistema.txt';
if (file_put_contents($filename, $fullSql) === false) {
throw new Exception("Erro ao salvar o arquivo $filename");
}
echo "Arquivo '$filename' criado com sucesso.\n";
} catch (Exception $e) {
echo "Erro: " . $e->getMessage() . "\n";
}
receberão um arquivo tablas_sistema.txt
DEVEM CRIAR ESTAS DUAS TABELAS
CREATE TABLE
cmp_table_catalog ( id int(10) unsigned NOT NULL AUTO_INCREMENT, table_name varchar(255) NOT NULL COMMENT 'Nome da tabela a analisar', is_enabled enum('enabled','disabled') NOT NULL DEFAULT 'enabled' COMMENT 'Estado da tabela: enabled ou disabled', created_at timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Data de criação', updated_at timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Última atualização', PRIMARY KEY (id)) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Catálogo de tabelas habilitadas para análise de componentes'CREATE TABLE
cmp_table_definitions_log ( id int(10) unsigned NOT NULL AUTO_INCREMENT, generated_sql longtext NOT NULL COMMENT 'Script SQL gerado com as definições de tabelas', created_at timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Data de geração do script', PRIMARY KEY (id)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Registro de scripts SQL gerados a partir das tabelas habilitadas'NA TABELA cmp_table_catalog coloquem o nome da tabela que querem buscar (coloquem todas as que quiserem).
luego executam este php
<?php
// COLOQUE SUAS CREDENCIAIS AQUI
$host = 'localhost';
$dbname = 'database';
$user = 'root';
$pass = '';
try {
// Criar conexão PDO
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]);
// Obter as tabelas habilitadas
$stmt = $pdo->prepare("SELECT table_name FROM cmp_table_catalog WHERE is_enabled = 'enabled'");
$stmt->execute();
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
if (empty($tables)) {
throw new Exception("Não há tabelas habilitadas em cmp_table_catalog.");
}
// Concatenar o SHOW CREATE TABLE de cada tabela
$fullSql = "";
foreach ($tables as $table) {
$stmt2 = $pdo->query("SHOW CREATE TABLE
$table");$row = $stmt2->fetch(PDO::FETCH_ASSOC);
if (!$row || !isset($row['Create Table'])) {
throw new Exception("Não foi possível obter SHOW CREATE TABLE para a tabela $table");
}
$fullSql .= $row['Create Table'] . ";\n\n";
}
// Salvar o SQL no arquivo tablas_sistema.txt
$filename = DIR . DIRECTORY_SEPARATOR . 'tablas_sistema.txt';
if (file_put_contents($filename, $fullSql) === false) {
throw new Exception("Erro ao salvar o arquivo $filename");
}
echo "Arquivo '$filename' criado com sucesso.\n";
} catch (Exception $e) {
echo "Erro: " . $e->getMessage() . "\n";
}
receberão um arquivo tablas_sistema.txt