Programming horror

in #programming8 years ago

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.

Sort:  

Great article!

Thanks for your good posts, I followed you! +UP

Congratulations @vmjoao! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

The Steem community has lost an epic member! Farewell @woflhart!
SteemitBoard - Witness Update
Do not miss the coming Rocky Mountain Steem Meetup and get a new community badge!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!