Commit
This commit is contained in:
parent
b1eace9941
commit
2753e6266a
11
app/lib/App/Teamtable/Team.php
Normal file
11
app/lib/App/Teamtable/Team.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Teamtable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a team in the teamtable
|
||||||
|
*/
|
||||||
|
class Team
|
||||||
|
{
|
||||||
|
// TODO...
|
||||||
|
}
|
@ -33,14 +33,19 @@ class Teamtable
|
|||||||
$sth->execute([$LagID]);
|
$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 = $this->dbh->prepare('SELECT * FROM lagtabell WHERE LagID = ?');
|
||||||
$sth->execute([$LagID]);
|
$sth->execute([$LagID]);
|
||||||
return $sth->fetch(PDO::FETCH_ASSOC);
|
return $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// why this is so long who cares???
|
/**
|
||||||
|
* Why this is so long who cares???
|
||||||
|
*/
|
||||||
public function updateTeamByID(
|
public function updateTeamByID(
|
||||||
int $id,
|
int $id,
|
||||||
string $LagNavn,
|
string $LagNavn,
|
||||||
@ -76,7 +81,9 @@ class Teamtable
|
|||||||
return $this->dbh->lastInsertId();
|
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
|
public function isEqualEmptyTemplate(array $team): bool
|
||||||
{
|
{
|
||||||
$template = $this->template;
|
$template = $this->template;
|
||||||
@ -88,8 +95,9 @@ class Teamtable
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if team exists, false if not
|
/**
|
||||||
// ;))
|
* Returns TRUE if team exists, FALSE if not
|
||||||
|
*/
|
||||||
public function recieveStick(string $cardnumber): bool
|
public function recieveStick(string $cardnumber): bool
|
||||||
{
|
{
|
||||||
$sth = $this->dbh->prepare('SELECT * FROM lagtabell WHERE Kortnummer = ?');
|
$sth = $this->dbh->prepare('SELECT * FROM lagtabell WHERE Kortnummer = ?');
|
||||||
@ -98,12 +106,12 @@ class Teamtable
|
|||||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
if ($row)
|
if ($row)
|
||||||
{
|
{
|
||||||
// Team exists, insert into time table
|
// team exists, insert into time table
|
||||||
$sth = $this->dbh->prepare('INSERT INTO tidtabell (LagID) VALUES (?)');
|
$sth = $this->dbh->prepare('INSERT INTO tidtabell (LagID) VALUES (?)');
|
||||||
$sth->execute([$row['LagID']]);
|
$sth->execute([$row['LagID']]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
// Team does not exist, lets create it
|
// team does not exist, lets create it
|
||||||
$sth = $this->dbh->prepare(
|
$sth = $this->dbh->prepare(
|
||||||
"INSERT INTO `lagtabell` (`LagNavn`, `Bedrift`, `Kortnummer`, `Lagleder`, `Telefon`, `Deltagere`, `Runder`) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
"INSERT INTO `lagtabell` (`LagNavn`, `Bedrift`, `Kortnummer`, `Lagleder`, `Telefon`, `Deltagere`, `Runder`) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user