wip: added rest api endpoint shiai

This commit is contained in:
marko
2023-12-26 20:24:34 +01:00
parent 49978a48df
commit f2cf7ff764
12 changed files with 245 additions and 44 deletions

View File

@@ -132,7 +132,7 @@ class ApiKey
// @todo differentiate between inserting and updating if the id is set it should only be updated (e.g. prolonging)
}
/** create an Api key from the return of an sql select * */
/** create an Api key from the return of an sql select */
private static function fromDbArray(array $apiKey)
{
return new ApiKey(

View File

@@ -28,7 +28,7 @@ class dbConnector
public static function query($aQueryString, $aBindArray = [], $someOptions = [])
{
// var_dump($aQueryString, $aBindArray);
// Standardbelegungen
// Standardbelegungen
if (empty($someOptions['dbCharset'])) {
$someOptions['dbCharset'] = 'ISO-8859-1';
}
@@ -65,7 +65,7 @@ class dbConnector
);
}
$pdoResult = $pdoStatement->execute();
if (!$ignoreErrors && !$pdoResult) {
if (!$ignoreErrors && !$pdoResult) {
echo("Error during dbQuery!\n");
echo("DB-Error:\n");
var_dump(self::$db->errorInfo());
@@ -128,6 +128,7 @@ class dbConnector
} else {
self::$db = null;
}
return $success;
}
public static function debugEchoQuery($query, $params)

View File

@@ -15,6 +15,12 @@ class Shiai
private $galleryUrl = null; //< url of the gallery to a gallery of the shiai
private $promoImgUrl = null; //< promotional image for the shiai (as url)
/** name of the table in the db holding the Shiai-s
*
* @var string
*/
private static $tableName = "wettkampfkalender";
public function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl, $promoImgUrl)
{
//! @todo input validation and sanitation
@@ -83,6 +89,17 @@ class Shiai
return self::fromDbArray($response[0]);
}
/** select shiai from the database
*
* - by default, only coming events will be returned
*/
public static function dbSelect(){
$query = "SELECT `".self::$tableName."`.* FROM `".self::$tableName."` WHERE `Datum` >= CURDATE();";
$response = dbConnector::query($query);
return $response;
}
public static function fromDbArray($member)
{
return new shiai(