2018-10-05 16:13:30 +00:00
|
|
|
<?php
|
|
|
|
class DB{
|
|
|
|
private $pdo;
|
|
|
|
|
|
|
|
public function __construct($dbpdo){
|
|
|
|
$this->pdo = $dbpdo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function loadSchema($schema_file){
|
|
|
|
$sql = file_get_contents($schema_file);
|
|
|
|
$this->pdo->exec($sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function insert($registro){
|
|
|
|
$sql = 'INSERT INTO Registro (nombre,apellido,titulo,afiliacion,ciudad,'
|
2018-10-16 16:35:45 +00:00
|
|
|
.'pais,email,fechaLlegada,fechaPartida,'
|
|
|
|
."cartaInvitacion,roomingPref,roommate,fechaRegistro)"
|
2018-10-05 16:13:30 +00:00
|
|
|
.' VALUES (:nombre,:apellido,:titulo,:afiliacion,:ciudad,:pais,:email,:fechaLlegada,'
|
2018-10-16 16:35:45 +00:00
|
|
|
.':fechaPartida,:cartaInvitacion,:roomingPref,:roommate,:fechaRegistro);';
|
2018-10-05 16:13:30 +00:00
|
|
|
|
|
|
|
$stmt = $this->pdo->prepare($sql);
|
|
|
|
$stmt->execute([
|
|
|
|
':nombre' => $registro['nombre'],
|
|
|
|
':apellido' => $registro['apellido'],
|
|
|
|
':titulo' => $registro['titulo'],
|
|
|
|
':afiliacion' => $registro['afiliacion'],
|
|
|
|
':ciudad' => $registro['ciudad'],
|
|
|
|
':pais' => $registro['pais'],
|
|
|
|
':email' => $registro['email'],
|
|
|
|
':fechaLlegada' => $registro['bda'],
|
|
|
|
':fechaPartida' => $registro['eda'],
|
2018-10-16 16:35:45 +00:00
|
|
|
//':financiacion' => $registro['financiacion'],
|
|
|
|
//':invitado' => $registro['invited'],
|
2018-10-05 16:13:30 +00:00
|
|
|
':cartaInvitacion' => $registro['letterinvited'],
|
|
|
|
':roomingPref' => $registro['roomtype'],
|
|
|
|
':roommate' => $registro['roomate'],
|
|
|
|
':fechaRegistro' => $date = date('Y-m-d H:i:s'),
|
|
|
|
]);
|
|
|
|
return $this->pdo->lastInsertId();
|
|
|
|
|
|
|
|
}
|
|
|
|
public function getAll(){
|
|
|
|
$stmt = $this->pdo->prepare("SELECT * FROM Registro ORDER BY apellido COLLATE NOCASE ASC");
|
|
|
|
$stmt -> execute();
|
|
|
|
return $stmt->fetchAll(\PDO::FETCH_BOTH);
|
|
|
|
|
|
|
|
}
|
|
|
|
public function getSpeakers(){
|
|
|
|
$stmt = $this->pdo->prepare("SELECT * FROM Speakers");
|
|
|
|
$stmt -> execute();
|
|
|
|
return $stmt->fetchAll(\PDO::FETCH_BOTH);
|
|
|
|
|
|
|
|
}
|
|
|
|
public function findByMail($email){
|
|
|
|
$stmt = $this->pdo->prepare("SELECT * FROM Registro WHERE email=:email");
|
|
|
|
$stmt->bindParam(":email",$email);
|
|
|
|
$stmt->execute();
|
|
|
|
return $result = $stmt->fetch(\PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|