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.

62 lines
1.5 KiB

<?php
namespace Gateway;
use Config\Connection;
use Config\ConnectClass;
use PDO;
use PDOException;
class GatewayKeyword
{
private Connection $connection;
public function __construct()
{
try{
$this->connection = (new ConnectClass)->connect();
}catch(PDOException $e){
throw new PDOException();
}
}
public function insertKeyword(array $keyword): void
{
$query = "INSERT INTO Keyword(word) VALUES(:word)";
$this->connection->executeQuery($query, array(
':word' => array($keyword[0], PDO::PARAM_STR)
));
}
public function deleteKeyword(array $keyword): void
{
$query = "DELETE FROM Keyword WHERE word = :word";
$this->connection->executeQuery($query, array(
':word' => array($keyword[0], PDO::PARAM_STR)
));
}
public function getAllKeyword(array $ignore): array
{
$query = "SELECT * FROM Keyword";
$this->connection->executeQuery($query);
return $this->connection->getResults();
}
public function getKeywordsContentByReference(array $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[0], PDO::PARAM_STR)
));
$tab = [];
foreach ($this->connection->getResults() as $result)
{
$tab[] = $result["word"];
}
return $tab;
}
}