php - How to cache this mysql query for the make and model of a vehicle? -


i have php code queries mysql database of year makes , models. year hard coded in php small amount of data. make , model queried database based on previous choices. ie: selecting 2012 allows makes of cars made in 2012 , after selecting make lists models made chosen make. below code have creates query select make. how can cache after called set amount of time speed subsequent queries? or possible?

i should mention hosting provider doesn't allow me turn caching on mysql. why try in php.

$year = $_post['year'];     // year post - sent via ajax  $vehmakes = $cl->getmakes($year); $output = '<option value="">-- makes --</option>'; while($row = mysql_fetch_row($vehmakes)){ $output .= '<option value="'.$row[0].'">'.$row[0].'</option>/n'; };  echo $output; 

thanks!

i write flat file comma separated list of makes given year , check if file exists before making db query. perhaps set timestamp in future in text file , check if has expired if create new cache file overwriting old.

if(file_exists($_post['year'].'.txt')) {  // file exists  $select_options = explode(",",file_get_contents($_post['year'].'.txt')); // loop through array options } else {  // make db query }  

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -