ptut-vhost/build/database/repo/category.php

34 lines
662 B
PHP

<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 20/02/18
* Time: 21:00
*/
namespace database\repo;
use database\core\Repo_i;
class category extends Repo_i{
public function createOrUpdate(int $id, string $label){
//create the category or update the label
$st = $this->pdo->prepare("INSERT INTO Categorie (idCategorie, labelCategorie) VALUES (:id, :label) ON DUPLICATE KEY UPDATE labelCategorie = :label;");
$st->execute([
"id" => $id,
"label" => $label
]);
}
public function delete(int $id) :bool{
$st = $this->pdo->prepare("DELETE FROM Categorie WHERE idCategorie = :id");
return $st->execute([
"id" => $id
]);
}
}