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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -