Reputation: 3571
I want to get data from a database which looks like this:
id - brand - type
1 Airbus plane
2 Boeing plane
3 Fokker plane
4 Toyota car
5 Mustang car
6 Peugeot car
7 Sparta bike
Now I want to e.g. output an <hr/>
whenever the type is different. I can do this two ways:
$current_type
and check its value with the one from the databaseWhich is the fastest? I would say the first but the second makes my code look so much better. Can I neglect the speed difference?
Upvotes: 0
Views: 81
Reputation: 131
The first one is definitely faster, I'd much rather have an extra temporary variable in my PHP code than 2 extra queries. The difference might be neglegible in your case, but it isn't be something I would give up for slightly neater code.
Upvotes: 1