sql - the same result in php or mysql ,which ways is better? -


    select * tablename.questions  date_sub(curdate(), interval 7 day) <=date( from_unixtime(question_created))         order question_click_count desc     ; 

to show 7days data
can in php

$day =  mktime(0,0,0,date("m"),date("d")-7,date("y")); 


and query sql

select * 'question' question_created < $day , xxxxxxx 


way better way?

doing in database much faster doing in php.

it's important consideration if it's happening inside of loop repeats 100000 times, if it's happening once not able tell difference.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -