Modify updating of rider table. #762

This commit is contained in:
Korina Cordero 2023-09-28 19:35:10 +08:00
parent 3e0084630f
commit 67635b07d5

View file

@ -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)