mirror of
https://github.com/itflow-org/itflow
synced 2026-03-03 20:34:51 +00:00
replace all instances of mysqli_fetch_array with mysqli_fetch_assoc for better performance and memory usage
This commit is contained in:
@@ -65,7 +65,7 @@ $sql_users = mysqli_query($mysqli, "
|
||||
LEFT JOIN user_settings on users.user_id = user_settings.user_id
|
||||
WHERE user_type = 1
|
||||
AND user_status = 1
|
||||
AND user_archived_at IS NULL
|
||||
AND user_archived_at IS NULL
|
||||
ORDER BY user_name DESC"
|
||||
);
|
||||
// TODO: Maybe try and filter this to just users with the support module perm
|
||||
@@ -83,7 +83,7 @@ $sql_users = mysqli_query($mysqli, "
|
||||
<form class="mb-3">
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_ticket_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_ticket_years)) {
|
||||
$ticket_year = intval($row['ticket_year']); ?>
|
||||
<option <?php if ($year == $ticket_year) { ?> selected <?php } ?> > <?php echo $ticket_year; ?></option>
|
||||
<?php } ?>
|
||||
@@ -108,13 +108,13 @@ $sql_users = mysqli_query($mysqli, "
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while ($agent_row = mysqli_fetch_array($sql_users)) {
|
||||
while ($agent_row = mysqli_fetch_assoc($sql_users)) {
|
||||
$user_id = intval($agent_row['user_id']);
|
||||
$user_name = nullable_htmlentities($agent_row['user_name']);
|
||||
|
||||
// Get tickets in period that are still assigned to the technician/agent
|
||||
$sql_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_assigned_to = $user_id");
|
||||
$row = mysqli_fetch_array($sql_ticket_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_count);
|
||||
$ticket_raised_count = intval($row['ticket_count']);
|
||||
|
||||
// Get unique tickets in period that the agent replied to/touched
|
||||
@@ -122,34 +122,34 @@ $sql_users = mysqli_query($mysqli, "
|
||||
SELECT COUNT(DISTINCT ticket_id) AS tickets_touched
|
||||
FROM (
|
||||
-- Tickets the agent replied to
|
||||
SELECT ticket_reply_ticket_id AS ticket_id
|
||||
FROM ticket_replies
|
||||
SELECT ticket_reply_ticket_id AS ticket_id
|
||||
FROM ticket_replies
|
||||
WHERE YEAR(ticket_reply_created_at) = $year AND ticket_reply_by = $user_id
|
||||
|
||||
|
||||
UNION
|
||||
|
||||
|
||||
-- Tickets the agent opened
|
||||
SELECT ticket_id
|
||||
FROM tickets
|
||||
SELECT ticket_id
|
||||
FROM tickets
|
||||
WHERE YEAR(ticket_created_at) = $year AND ticket_created_by = $user_id
|
||||
|
||||
|
||||
UNION
|
||||
|
||||
|
||||
-- Tickets the agent closed
|
||||
SELECT ticket_id
|
||||
FROM tickets
|
||||
SELECT ticket_id
|
||||
FROM tickets
|
||||
WHERE YEAR(ticket_created_at) = $year AND ticket_closed_by = $user_id
|
||||
)
|
||||
AS tickets_touched
|
||||
");
|
||||
|
||||
$row = mysqli_fetch_array($sql_tickets_touched);
|
||||
$row = mysqli_fetch_assoc($sql_tickets_touched);
|
||||
$tickets_touched = intval($row['tickets_touched']);
|
||||
|
||||
|
||||
// Calculate total time tracked towards tickets in the period (for this agent)
|
||||
$sql_time = mysqli_query($mysqli, "SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ticket_reply_time_worked))) as total_time FROM ticket_replies LEFT JOIN tickets ON tickets.ticket_id = ticket_replies.ticket_reply_ticket_id WHERE YEAR(ticket_created_at) = $year AND ticket_reply_by = $user_id AND ticket_reply_time_worked IS NOT NULL");
|
||||
$row = mysqli_fetch_array($sql_time);
|
||||
$row = mysqli_fetch_assoc($sql_time);
|
||||
$ticket_total_time_worked = nullable_htmlentities($row['total_time']);
|
||||
|
||||
?>
|
||||
@@ -178,4 +178,3 @@ $sql_users = mysqli_query($mysqli, "
|
||||
|
||||
<?php
|
||||
require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user