Hello!
I just made some speed tests getting configuration from DB.
For now I figured 2 ways doing this.
1. One value in each row
id | name | val ---------------------- 1 | name1 | value1 ........
2. using serialize($config) and saving this in one row. $config is predefined array of configuration.
I test this with 100 config values. First I read all 100 rows for 1st example, then I read only one row and then unserialize this to get array.
Here is result:
1st example 0.0478450059891 86.74% 2nd example 0.0073139667511 13.26%
There you can see speed of second example. I wan't to know what do you think about this. And what's your solutions of reading config from DB. I saw that many big project still use first example.
Question: How many people selected 'blue' for their config color?
1. SELECT COUNT(*) FROM Table WHERE config_color = 'blue';
2. ?? SELECT COUNT(*) FROM Table WHERE serialized_column LIKE '"config_color";s:4:"blue";'
Basically, method 1 is more flexible. With method 2, you'll need to store it in a TEXT column or hope your serialized value never goes over 255 characters.
-- ---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
PHP|Architect: A magazine for PHP Professionals – www.phparch.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php