110 lines
No EOL
2.7 KiB
PHP
110 lines
No EOL
2.7 KiB
PHP
<?php
|
|
/*
|
|
* Copyright (C) 2021 Eichehome
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
class Datenbank extends DBClass
|
|
{
|
|
/**
|
|
*
|
|
* @param string $name
|
|
* @param string $passwort
|
|
* @return boolean
|
|
*/
|
|
public function checkLogin(string $name, string $passwort)
|
|
{
|
|
$sql = 'SELECT * FROM Test_v2 WHERE Name=:name AND Code=:passwort';
|
|
|
|
$params = array(
|
|
'name' => strtolower($name),
|
|
'passwort' => $passwort
|
|
);
|
|
|
|
$result = $this->select($sql, $params);
|
|
|
|
if (count($result) == 1) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param string $name
|
|
* @return boolean
|
|
*/
|
|
public function hasAlredySelected(string $name)
|
|
{
|
|
$sql = 'SELECT * FROM Test_v2 WHERE Name=:name AND Kurs IS NOT NULL AND Kurs2 IS NOT NULL AND Kurs3 IS NOT NULL ';
|
|
|
|
$params = array(
|
|
'name' => $name
|
|
);
|
|
|
|
$result = $this->select($sql, $params);
|
|
|
|
if (count($result) == 1) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return array strings
|
|
*/
|
|
public function selectKurse()
|
|
{
|
|
$sql = 'SELECT name, stunde FROM Kurse';
|
|
|
|
return $this->select($sql);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param array $kurse
|
|
* @return boolean
|
|
*/
|
|
public function insertSelection(string $name, array $kurse)
|
|
{
|
|
if (count($kurse) == 3) {
|
|
$sql = 'UPDATE Test_v2 SET Kurs=:kurs1, Kurs2=:kurs2, Kurs3=:kurs3 WHERE name =:name';
|
|
|
|
$params = array(
|
|
'name' => $name,
|
|
'kurs1' => $kurse[0],
|
|
'kurs2' => $kurse[1],
|
|
'kurs3' => $kurse[2]
|
|
);
|
|
|
|
return $this->query($sql, $params);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Nichtmehr nötig
|
|
* @param string $name
|
|
* @return boolean
|
|
*/
|
|
/*public function updateHasAlredySelected(string $name)
|
|
{
|
|
return true;
|
|
}*/
|
|
} |