You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
engelsystem/includes/model/EventConfig_model.php

86 lines
1.9 KiB
PHTML

<?php
use Engelsystem\Database\DB;
/**
* Get event config.
*
* @return array|null
*/
8 years ago
function EventConfig()
{
$event_config = DB::select('SELECT * FROM `EventConfig` LIMIT 1');
if (DB::getStm()->errorCode() != '00000') {
engelsystem_error('Unable to load event config.');
return null;
8 years ago
}
if (empty($event_config)) {
return null;
8 years ago
}
return array_shift($event_config);
}
/**
* Update event config.
*
8 years ago
* @param string $event_name
8 years ago
* @param int $buildup_start_date
* @param int $event_start_date
* @param int $event_end_date
* @param int $teardown_end_date
8 years ago
* @param string $event_welcome_msg
* @return bool
*/
8 years ago
function EventConfig_update(
$event_name,
$buildup_start_date,
$event_start_date,
$event_end_date,
$teardown_end_date,
$event_welcome_msg
) {
8 years ago
if (EventConfig() == null) {
return DB::insert('
INSERT INTO `EventConfig` (
`event_name`,
`buildup_start_date`,
`event_start_date`,
`event_end_date`,
`teardown_end_date`,
`event_welcome_msg`
)
VALUES (?, ?, ?, ?, ?, ?)
',
[
$event_name,
$buildup_start_date,
$event_start_date,
$event_end_date,
$teardown_end_date,
$event_welcome_msg
]
);
8 years ago
}
return (bool)DB::update('
UPDATE `EventConfig` SET
`event_name` = ?,
`buildup_start_date` = ?,
`event_start_date` = ?,
`event_end_date` = ?,
8 years ago
`teardown_end_date` = ?,
`event_welcome_msg` = ?
',
[
$event_name,
$buildup_start_date,
$event_start_date,
$event_end_date,
$teardown_end_date,
$event_welcome_msg,
]
);
}