is it better to query database or grab from file? php & mysql
- by pfunc
I am keeping a large amount of words in a database that I want to match up articles to. I was thinking that it would just be better to keep these words in an array and grab that array whenever needed instead of querying the database every time (since the words won't be changing that much).
Is there much performance difference in doing this?
And if I were to do this, how to I write a script that writes the array to a a new php file. I tried writing the array like so:
while( $row = mysql_fetch_assoc($query))
{
$newArray[] = $row;
}
$fp = fopen('noWordsArr.php', 'w');
fwrite($fp, $newArray);
fclose($fp);
But all I get in the other file is "Array".
So i figured I could write this and then write have a chron hit up the file every few days or so in case things have changed. But I guess if there is no performance advantage then it prob won't be necessary and I can just query the database every time I need to access the words.