You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
<?php
|
|
|
|
require "gateways/UserGateway.php";
|
|
require "business/User.php";
|
|
|
|
class Model
|
|
{
|
|
public function getInformationsUser($id): array
|
|
{
|
|
global $app;
|
|
$db = $app->getContainer()['settings']['db'];
|
|
$id = filter_var($id, FILTER_SANITIZE_STRING);
|
|
$gw = new UserGateway(new Connection($db['dsn'], $db['user'], $db['pass']));
|
|
$userDb = $gw->getInformations($id);
|
|
if (count($userDb) != 1) {
|
|
throw new Exception("no user matches id");
|
|
}
|
|
$user = new User($userDb[0][0], $userDb[0][1]);
|
|
return $user->getInformations();
|
|
}
|
|
|
|
public function addUser($idDafl, $idSpotify, $passw): void
|
|
{
|
|
global $app;
|
|
$db = $app->getContainer()['settings']['db'];
|
|
|
|
$data = [];
|
|
$data['idDafl'] = filter_var($idDafl, FILTER_SANITIZE_STRING);
|
|
$data['idSpotify'] = filter_var($idSpotify, FILTER_SANITIZE_STRING);
|
|
$data['passw'] = filter_var($passw, FILTER_SANITIZE_STRING);
|
|
$gw = new UserGateway(new Connection($db['dsn'], $db['user'], $db['pass']));
|
|
$gw->addUser($data['idDafl'], $data['idSpotify'], $data['passw']);
|
|
}
|
|
} |