This commit is contained in:
William 2022-03-02 07:24:27 +01:00
parent b1eace9941
commit 2753e6266a
2 changed files with 26 additions and 7 deletions

View File

@ -0,0 +1,11 @@
<?php
namespace App\Teamtable;
/**
* Represents a team in the teamtable
*/
class Team
{
// TODO...
}

View File

@ -33,14 +33,19 @@ class Teamtable
$sth->execute([$LagID]);
}
public function getTeamByID(int $LagID) # Mixed, array if exists, false if not
/**
* Returns mixed, array if exists, FALSE if not.
*/
public function getTeamByID(int $LagID)
{
$sth = $this->dbh->prepare('SELECT * FROM lagtabell WHERE LagID = ?');
$sth->execute([$LagID]);
return $sth->fetch(PDO::FETCH_ASSOC);
}
// why this is so long who cares???
/**
* Why this is so long who cares???
*/
public function updateTeamByID(
int $id,
string $LagNavn,
@ -76,7 +81,9 @@ class Teamtable
return $this->dbh->lastInsertId();
}
// Check if team is empty by comparing it to the template
/**
* Check if team is empty by comparing it to the template
*/
public function isEqualEmptyTemplate(array $team): bool
{
$template = $this->template;
@ -88,8 +95,9 @@ class Teamtable
return TRUE;
}
// Return true if team exists, false if not
// ;))
/**
* Returns TRUE if team exists, FALSE if not
*/
public function recieveStick(string $cardnumber): bool
{
$sth = $this->dbh->prepare('SELECT * FROM lagtabell WHERE Kortnummer = ?');
@ -98,12 +106,12 @@ class Teamtable
$row = $sth->fetch(PDO::FETCH_ASSOC);
if ($row)
{
// Team exists, insert into time table
// team exists, insert into time table
$sth = $this->dbh->prepare('INSERT INTO tidtabell (LagID) VALUES (?)');
$sth->execute([$row['LagID']]);
return TRUE;
}
// Team does not exist, lets create it
// team does not exist, lets create it
$sth = $this->dbh->prepare(
"INSERT INTO `lagtabell` (`LagNavn`, `Bedrift`, `Kortnummer`, `Lagleder`, `Telefon`, `Deltagere`, `Runder`) VALUES (?, ?, ?, ?, ?, ?, ?)"
);