diff options
author | Jan-Philipp Litza <janphilipp@litza.de> | 2011-12-27 13:50:07 +0100 |
---|---|---|
committer | Jan-Philipp Litza <janphilipp@litza.de> | 2011-12-27 13:50:07 +0100 |
commit | d3b51174b6ba00c06d6e84c13247793744b8c99a (patch) | |
tree | eb5e9ccb557f58df0e8fc8530917340174bac362 | |
parent | c925f19a96fc2dcbb058acb91fc5d96ce877d8eb (diff) |
performance improvements for displaying shifts
-rw-r--r-- | includes/pages/user_shifts.php | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index e0e8b1bc..3088e633 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -210,13 +210,12 @@ function user_shifts() { 'comment' => "" )); } else { - $shifts = sql_select("SELECT * FROM `Shifts` ORDER BY `start`"); + $shifts = sql_select("SELECT COUNT(*) AS `count` FROM `Shifts` ORDER BY `start`"); $days = array (); $rooms = array (); - if (count($shifts) > 0) { - foreach ($shifts as $shift) - $days[] = date("Y-m-d", $shift['start']); - $days = array_unique($days); + if ($shifts[0]["count"] > 0) { + $days = sql_select("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) FROM `Shifts`"); + $days = array_map('array_pop', $days); $day = $days[0]; if (isset ($_REQUEST['day'])) $day = $_REQUEST['day']; |