« Setting Environment Paths With paths.inc.php | Main | Moonlight Mile »
March 27, 2009
Setting Up Database Connection Credentials With .ini Files
Database credentials are stored in the common_php directory in Windows .ini format files.
[connection_parameters] user = youruser password = yourpasswordhere host = localhost type = mysql db = blah
This file should be saved as a .ini file in common_php, and usually with the name of your DB. So for a db named blah, you would name the file blah.ini, and also set $db_name = 'blah'; in your applications paths.inc.php file.
If for extra security you want to name your .ini file something else then that's fine as long as to set $db_name to that.
When the just_sql() function is called it looks for a .ini file named after whatever $db_name is set to, and then parses the contents of that file into a hash to extract the connection credentials and open up a connection before performing the SQL transaction.
The .ini files are protected from view from the webserver using a .htaccess file:
<Files *.ini> order deny,allow deny from all </Files>
Tags: Lightweight PHP Web Application Framework
Posted by pj at March 27, 2009 05:22 PM