Reputation: 736
Which makes website more speedy retrieve data from a MySQL Database or test value inside PHP script
It is interesting for me to find answer for this question. I have 2 options for displaying data in my website.
To call from database like that:
SELECT *, CASE WHEN u.sex='1' THEN 'Male' WHEN u.sex='2' THEN 'Female' END AS 'Sex' FROM users u LIMIT 30
test value inside PHP script
<?php
if ($sex==1) {$sex='Male'} else {$sex='Female'}
?>
Upvotes: 3
Views: 1173
Reputation: 11275
The first one is faster. There is no need to pull data to process it again at PHP layer.
Upvotes: 2