Programming horror

Words
17
Reading
1 min
Listen
Play
9y

Today I got a code at work that was doing something like:

  for($i = 0; $i < count($students->fetchAll()); $i++) {
     $name = $students->fetchAll()[$i]['name'];
     $age = $students->fetchAll()[$i]['age'];
  ...  
}

fetchAll() hits the database. Kill me.