Page 1 of 1

db.php without using PEAR

Posted: Fri Nov 21, 2008 11:50 pm
by RiceBallAttack
Hi!
I'm doing a project and we belatedly realized that the correct thing to do was to have a file called db.php, which made the connection to the database, that we require_once on every page. This way, if the connection string changes, only one file needs to be edited. Everything I've found on how to do this says, "Use PEAR! It's easy and does it for you!"
However, the project is due quite soon [i.e. in a few days] and I don't have the time to a) learn PEAR and b) implement that throughout the entire site (which will probably have to be restructured).
Does anyone know another way to do this or where I could look for more info? Thanks!

Re: db.php without using PEAR

Posted: Sat Nov 22, 2008 12:11 am
by requinix
How about you... make it yourself?

If you already use mysql_query/other applicable function then this db.php only needs to make the connection. That is, whatever all the files have in common you just stick into your db.php file.

Re: db.php without using PEAR

Posted: Sat Nov 22, 2008 11:47 am
by califdon
RiceBallAttack wrote:Hi!
I'm doing a project and we belatedly realized that the correct thing to do was to have a file called db.php, which made the connection to the database, that we require_once on every page. This way, if the connection string changes, only one file needs to be edited. Everything I've found on how to do this says, "Use PEAR! It's easy and does it for you!"
However, the project is due quite soon [i.e. in a few days] and I don't have the time to a) learn PEAR and b) implement that throughout the entire site (which will probably have to be restructured).
Does anyone know another way to do this or where I could look for more info? Thanks!
There is no need to use PEAR. I have never used it. PEAR can be a most useful library and simplify and standardize your PHP database programming, but it's perfectly acceptable to not use it. In other words, it's an excellent programming tool, but when you are working against a deadline and have most of the work already done, don't even consider it. At least, that's my advice.