-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.php
More file actions
70 lines (55 loc) · 1.39 KB
/
debug.php
File metadata and controls
70 lines (55 loc) · 1.39 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require_once('inc/config.php');
// Función para limpiar tabla y reiniciar los IDs a 1
function limpiarTabla($tableName)
{
global $conn;
try {
// Limpiar tabla
$conn->query("DELETE FROM $tableName");
// Reiniciar ID a 1
$conn->query("ALTER TABLE $tableName AUTO_INCREMENT = 1");
return true;
} catch (Exception $e) {
return false;
}
}
// Comprobar si se hizo clic en el botón "Limpiar tablas"
if (isset($_POST['limpiarTablas'])) {
$tablas = array(
"UtilesEstudiante",
"Estudiantes",
"ListaDeUtiles",
"Grados"
);
$exitoso = true;
foreach ($tablas as $tabla) {
$resultado = limpiarTabla($tabla);
if (!$resultado) {
$exitoso = false;
break;
}
}
if ($exitoso) {
$mensaje = "Las tablas se limpiaron y los IDs se reiniciaron a 1.";
} else {
$mensaje = "Error al limpiar las tablas.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Limpiar tablas y reiniciar IDs</title>
</head>
<body>
<h2>Limpiar tablas y reiniciar IDs</h2>
<?php if (isset($mensaje)) { ?>
<p><?php echo $mensaje; ?></p>
<?php } ?>
<form method="POST" action="">
<input type="hidden" name="limpiarTablas" value="true">
<button type="submit">Limpiar tablas y reiniciar IDs</button>
</form>
</body>
</html>