parent
e3e4a47226
commit
f8b04c7ab3
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace config;
|
||||
class Connection extends PDO {
|
||||
|
||||
private $stmt;
|
||||
|
||||
public function __construct(string $dsn, string $username, string $password) {
|
||||
|
||||
parent::__construct($dsn,$username,$password);
|
||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
/** * @param string $query
|
||||
* @param array $parameters *
|
||||
* @return bool Returns `true` on success, `false` otherwise
|
||||
*/
|
||||
|
||||
public function executeQuery(string $query, array $parameters = []) : bool{
|
||||
$this->stmt = parent::prepare($query);
|
||||
foreach ($parameters as $name => $value) {
|
||||
$this->stmt->bindValue($name, $value[0], $value[1]);
|
||||
}
|
||||
|
||||
return $this->stmt->execute();
|
||||
}
|
||||
|
||||
public function getResults() : array {
|
||||
return $this->stmt->fetchall();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace model;
|
||||
|
||||
use function Sodium\add;
|
||||
|
||||
class Group
|
||||
{
|
||||
private int $id;
|
||||
private int $num;
|
||||
private int $year;
|
||||
private string $sector;
|
||||
private array $students;
|
||||
private array $vocabs;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $num
|
||||
* @param int $year
|
||||
* @param string $sector
|
||||
*/
|
||||
public function __construct(int $id, int $num, int $year, string $sector, array $students, array $vocab)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->num = $num;
|
||||
$this->year = $year;
|
||||
$this->sector = $sector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNum(): int
|
||||
{
|
||||
return $this->num;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getYear(): int
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSector(): string
|
||||
{
|
||||
return $this->sector;
|
||||
}
|
||||
|
||||
public function addUser(Users $user){
|
||||
$this->students.add($user);
|
||||
}
|
||||
|
||||
public function removeUser(Users $user){
|
||||
$this->students . remove($user);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue