From 67635b07d593c57e5076ff95b5c3d002b9691ce2 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 28 Sep 2023 19:35:10 +0800 Subject: [PATCH] Modify updating of rider table. #762 --- src/Command/GetJobOrderArchiveDataCommand.php | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Command/GetJobOrderArchiveDataCommand.php b/src/Command/GetJobOrderArchiveDataCommand.php index e266f6dd..e5ac289d 100644 --- a/src/Command/GetJobOrderArchiveDataCommand.php +++ b/src/Command/GetJobOrderArchiveDataCommand.php @@ -850,23 +850,19 @@ class GetJobOrderArchiveDataCommand extends Command protected function updateRiderJobOrders($jo_id_list) { - // TODO: memory exception while updating rider table. - // need to figure out how to make this not run out of memory. - // first draft had us selecting and finding the rider ids. maybe we should bring - // that back with the set attribute? I can't remember if I ran it with that one :( - // so that updating will have a smaller result set. + // TODO: test this $db = $this->em->getConnection(); - $db->getWrappedConnection()->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - $update_sql = 'UPDATE rider SET current_jo_id = NULL, active_jo_id = NULL WHERE (current_jo_id = :id OR active_jo_id = :id)'; - $update_stmt = $db->prepare($update_sql); + $jo_ids = str_repeat('?,', count($jo_id_list) - 1) . '?'; - foreach ($jo_id_list as $jo_id) - { - $update_stmt->execute([ - 'id' => $jo_id, - ]); - } + $update_curr_sql = 'UPDATE rider SET current_jo_id = NULL WHERE current_jo_id IN (' . $jo_ids . ')'; + $update_curr_stmt = $db->prepare($update_curr_sql); + + $update_active_sql = 'UPDATE rider SET active_jo_id = NULL WHERE active_jo_id IN (' . $jo_ids . ')'; + $udpate_active_stmt = $db->prepare($update_active_sql); + + $update_curr_stmt->execute($jo_id_list); + $update_active_stmt->execute($jo_id_list); } protected function loadDataFileForArchiveData($load_stmt)