[ciapug] DB Manager Configuration file best practice?

Tony Bibbs tony at tonybibbs.com
Thu Mar 23 16:02:43 CST 2006


In Geeklog (and most our projects at work) we do this:

config.php

$conf['db_name'] = '';
$conf['db_host'] = '';
$conf['db_user'] = '';
$conf['db_pass'] = '';

then other config values:

$conf['cookie_name'] = '';
$conf['cookie_timeout'] = '';

Works fine for me.

--Tony

Wade Arnold wrote:
> I am wondering if anyone has a best practice for setting up a configuration
> file for my database connection variables
> 
> In the past I have used the code below but now that I am using classes it
> fails to declare the constant. Any ideas or tidbits of wisdom?
> 
> Thanks;
> Wade Arnold
> 
> <?php
> // this will be in your DBManager.php
> require_once dirname(__FILE__).'./conf/_dbconfig.inc';
> 
> echo DB_USER;
> echo DB_PASSWORD;
> echo DB_PASSWORD;
> echo DB_HOST;
> ?>
> 
> 
> <?php
> // name this file _dbconfig.inc
> 
> /**
>  * Thide defines CONSTANTS
>  */
> define( 'DB_USER', 'wadearno_bvlt1' );      // your MySQL username
> define( 'DB_PASSWORD', 'zorwvMw5OV2L' );  // ...and password
> define( 'DB_PASSWORD', 'wadearno_bvlt1' );   // the name of the database
> define( 'DB_HOST', 'localhost' );     // mySQL Server (typically
> 'localhost')
> ?>
> 
> _______________________________________________
> ciapug mailing list
> ciapug at cialug.org
> http://cialug.org/mailman/listinfo/ciapug


More information about the ciapug mailing list