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.
SAE4.01_FORMULAIRE/Source/API/script/Gateway/GatewayKeyword.php

58 lines
1.4 KiB

<?php
namespace API\script\Gateway;
use API\script\Config\Connection;
use PDO;
class GatewayKeyword
{
private Connection $connection;
public function __construct()
{
$this->connection = connect();
}
public function insertKeyword(string $keyword)
{
$query = "INSERT INTO Keyword(word) VALUES(:word)";
$this->connection->executeQuery($query, array(
':word' => array($keyword, PDO::PARAM_STR)
));
}
public function deleteKeyword(string $keyword)
{
$query = "DELETE FROM Keyword WHERE word = :word";
$this->connection->executeQuery($query, array(
':word' => array($keyword, PDO::PARAM_STR)
));
}
public function getAllKeyword(): array
{
$query = "SELECT * FROM Keyword";
$this->connection->executeQuery($query);
return $this->connection->getResults();
}
public function getKeywordsContentByReference(int $id): array
{
$query = "SELECT k.* FROM Keyword k, Reference r
WHERE k.word = r.keyword AND r.possibleResponse = :id";
$this->connection->executeQuery($query, array(
':id' => array($id, PDO::PARAM_STR)
));
$tab = [];
foreach ($this->connection->getResults() as $result) {
$tab[] = $result["word"];
}
return $tab;
}
}