I've been thinking of doing something like this one something I'm working on.
If I do it, I'll probably just have a configuration table in the DB that only has one row.
Then I'll just select the row from the DB, and write the values to a .php file.
Here's a real simple(untested) example:
PHP Code:
<?php
$result = mysql_query("SELECT * FROM config");
$row = mysql_fetch_assoc($result);
$fp = fopen('/file/to/config.php', 'w');
fwrite($fp, '$CONFIG[\'var1\'] = '.$row['columnName1'].";\n");
fwrite($fp, '$CONFIG[\'var2\'] = '.$row['columnName2'].";\n");
fwrite($fp, '$CONFIG[\'var3\'] = '.$row['columnName3'].";\n");
fwrite($fp, '$CONFIG[\'var4\'] = '.$row['columnName4'].";\n");
fwrite($fp, '$CONFIG[\'var5\'] = '.$row['columnName5'].";\n");
fwrite($fp, '$CONFIG[\'var6\'] = '.$row['columnName6'].";\n");
fwrite($fp, '$CONFIG[\'var7\'] = '.$row['columnName7'].";\n");
/*
Could also use DEFINE:
fwrite($fp, 'DEFINE(\'CONST_NAME\', '.$row['columnName'].")\n");
*/
fclose($fp);
?>
BUt if you're caching the output with something like Pear::Cache_Lite , I don't guess you really have to worry about it.
--ed
Bookmarks