ggdworkshop/db/db.php

47 lines
1.4 KiB
PHP
Raw Normal View History

<?php
class DB extends SQLite3{
function __construct(){
$this->open('./ggdworkshop.db');
}
function schema(){
$sql =<<<EOF
CREATE TABLE IF NOT EXISTS Registro
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
nombre VARCHAR(50) NOT NULL,
apellido VARCHAR(50) NOT NULL,
titulo VARCHAR(50),
afiliacion VARCHAR(50),
ciudad VARCHAR(50),
pais VARCHAR(50),
email VARCHAR(80) NOT NULL UNIQUE,
fechaLlegada DATE,
fechaPartida DATE,
financiacion BOOLEAN NOT NULL,
invitado BOOLEAN NOT NULL,
cartaInvitacion BOOELAN NOT NULL,
roomingPref VARCHAR(50),
roommate VARCHAR(50),
fechaRegistro DATETIME NOT NULL
);
EOF;
$ret = $this->exec($sql);
if(!$ret){
echo $this->lastErrorMsg();
} else {
echo "Schema created successfully\n";
}
$this->close();
}
}
$db = new DB();
if(!$db){
echo $db->lastErrorMsg();
}else{
echo "Opened database successfully\n";
}
$db->schema();
?>