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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -