[ciapug] DB Manager Configuration file best practice?
David Champion
dchampion at visionary.com
Thu Mar 23 14:20:15 CST 2006
Is this a scope issue? You could include the _dbconfig.inc in your class
code, or wherever you're instantiating the db object, and set the
properties for the object...
BTW - I would recommend that you don't name include files .inc. If you
don't specifically configure your web server to deny showing this file
type on every server you're using it on, people will be able to do this:
http://yourserver.com/_dbconfig.inc
... and see the contents of that file.
-dc
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