Subir archivos a "Interfaz/control"
This commit is contained in:
parent
7054e8b6af
commit
789acde865
Interfaz/control
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
require 'conexionbd.php';
|
||||
|
||||
$artistas = ['The Driver Era', 'The 1975', 'Taylor Swift'];
|
||||
$dias = [22, 23, 24];
|
||||
$filas = 10;
|
||||
$columnas = 12;
|
||||
|
||||
try {
|
||||
$stmt = $conn->query("SELECT COUNT(*) AS total FROM asientos");
|
||||
$resultado = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($resultado['total'] > 0) {
|
||||
echo "La base de datos ya ha sido inicializada. No se insertaron nuevos asientos.";
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO asientos (artista, dia, asiento, estado) VALUES (:artista, :dia, :asiento, 'disponible')");
|
||||
|
||||
foreach ($artistas as $artista) {
|
||||
foreach ($dias as $dia) {
|
||||
for ($i = 1; $i <= $filas; $i++) {
|
||||
for ($j = 0; $j < $columnas; $j++) {
|
||||
$asiento = $i . chr(65 + $j);
|
||||
$stmt->execute([
|
||||
':artista' => $artista,
|
||||
':dia' => $dia,
|
||||
':asiento' => $asiento
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "Base de datos inicializada correctamente.";
|
||||
} catch (PDOException $e) {
|
||||
die("Error al inicializar la base de datos: " . $e->getMessage());
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue