45 lines
880 B
PHP
45 lines
880 B
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: lucas
|
|
* Date: 20/02/18
|
|
* Time: 21:35
|
|
*/
|
|
|
|
namespace database\repo;
|
|
|
|
|
|
use database\core\Repo_i;
|
|
|
|
class formation extends Repo_i {
|
|
|
|
public function create(string $label, bool $isInternal) : int{
|
|
$st = $this->pdo->prepare("INSERT INTO Formation (labelFormation, isInternal) VALUE (:label,:isInternal);");
|
|
|
|
$st->execute([
|
|
"label" => $label,
|
|
"isInternal" => $isInternal? 1 : 0
|
|
]);
|
|
|
|
return $this->pdo->lastInsertId();
|
|
}
|
|
|
|
public function exists(string $label) : int{
|
|
$st = $this->pdo->prepare("SELECT idFormation FROM Formation WHERE labelFormation = :label");
|
|
|
|
$st->execute([
|
|
"label" => $label
|
|
]);
|
|
|
|
return $st->fetch()["idFormation"]?: 0;
|
|
}
|
|
|
|
public function delete(int $id) : bool{
|
|
$st = $this->pdo->prepare("DELETE FROM Formation WHERE idFormation = :id");
|
|
|
|
return $st->execute([
|
|
"id" => $id
|
|
]);
|
|
}
|
|
|
|
} |