[PHP-DB] Re: SQL or array ?
Okay, thanks all. I think what I'll do is save the data in a DB, and then read it in to an array when the script is first called. That way it doesn't need to perform the SQL query per mime_type hundreds of times, and can just key it from the array. How would I go about benchmarking the different options? What tools are there to do this? Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SQL or array ?
I have a quick question about which would the best way to implement something in terms of performance. Using a database, or just creating a big array in memory? I have a PHP file manager script which creates an array of all files in a directory, and get's their mime types. It then prints these files to the browser with a little image or a word icon etc for word documents. So the data looks a bit like this: +--++---+--+ | id | mime_type | description | icon | +--++---+--+ |0 | text/html | HTML document | html.png | |1 | application/msword | Word document | word.png | +--++---+--+ But this means for every file it comes across it needs to do an SQL query to find the description and icon name. Which doesn't seem very efficient. Would it be better to just create a big array at the start of my script with all this data in? That would seem more efficient, and hence faster way of doing it? Any feedback appreciated. Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL or array ?
explain the phrase big array. I guess everything is relative! We're talking about 300-500 items here. Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php