Commit 743643e1 authored by Rémy Huet's avatar Rémy Huet 💻

Encapsulation and params types

parent 1fbeb0e3
......@@ -4,7 +4,7 @@ class DB {
private $conn;
function __construct () {
public function __construct () {
include 'connexion.php';
try {
$this->conn = new PDO('pgsql:host=localhost;port=5432;dbname=apisub', $db_user, $db_pass);
......@@ -13,7 +13,7 @@ class DB {
}
}
function subList(string $utclogin) : array {
public function subList(string $utclogin) : array {
$sql = 'SELECT *
FROM vsubscription
WHERE utclogin=:utclogin';
......@@ -26,7 +26,7 @@ class DB {
return $res;
}
function apiList(string $semester, int $year) : array {
public function apiList(string $semester, int $year) : array {
$sql = 'SELECT *
FROM vApi
WHERE semester=:semester AND year=:year';
......@@ -40,7 +40,7 @@ class DB {
return $res;
}
function subToApi($utclogin, $api) : bool {
public function subToApi(string $utclogin, int $api) : bool {
$today = date('Ymd');
$sql = 'INSERT INTO subscribe(utclogin, api, subdate) VALUES (:utclogin, :api, :today)';
$st = $this->conn->prepare($sql);
......@@ -53,7 +53,7 @@ class DB {
return $res;
}
function unsubToApi($utclogin, $api) : bool {
public function unsubToApi(string $utclogin, int $api) : bool {
$sql = 'DELETE FROM subscribe WHERE utclogin=:utclogin AND api=:api';
$st = $this->conn->prepare($sql);
$res = $st->execute([
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment