diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2017-01-21 13:58:53 +0100 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2017-01-21 13:58:53 +0100 |
commit | 9a3ad8883403949a59e8935497a548ec536f1d40 (patch) | |
tree | d3c27912c925e53bc240640ccc1133d8f87f1fd3 /includes/pages/guest_stats.php | |
parent | f7c09cb7ff84db1004a4fa83a70735475702023f (diff) |
Changed from mysqli to PDO, some refactorings, faster sql queries
Diffstat (limited to 'includes/pages/guest_stats.php')
-rw-r--r-- | includes/pages/guest_stats.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/includes/pages/guest_stats.php b/includes/pages/guest_stats.php index c4e1af74..4add3e97 100644 --- a/includes/pages/guest_stats.php +++ b/includes/pages/guest_stats.php @@ -1,5 +1,7 @@ <?php +use Engelsystem\Database\DB; + function guest_stats() { global $api_key; @@ -8,21 +10,23 @@ function guest_stats() if ($_REQUEST['api_key'] == $api_key) { $stats = []; - list($user_count) = sql_select('SELECT count(*) AS `user_count` FROM `User`'); + list($user_count) = DB::select('SELECT count(*) AS `user_count` FROM `User`'); $stats['user_count'] = $user_count['user_count']; - list($arrived_user_count) = sql_select('SELECT count(*) AS `user_count` FROM `User` WHERE `Gekommen`=1'); + list($arrived_user_count) = DB::select('SELECT count(*) AS `user_count` FROM `User` WHERE `Gekommen`=1'); $stats['arrived_user_count'] = $arrived_user_count['user_count']; - $done_shifts_seconds = sql_select_single_cell(' + $done_shifts_seconds = DB::select(' SELECT SUM(`Shifts`.`end` - `Shifts`.`start`) FROM `ShiftEntry` JOIN `Shifts` USING (`SID`) WHERE `Shifts`.`end` < UNIX_TIMESTAMP() '); + $done_shifts_seconds = array_shift($done_shifts_seconds); + $done_shifts_seconds = (int)array_shift($done_shifts_seconds); $stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0); - $users_in_action = sql_select(' + $users_in_action = DB::select(' SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` |