db.php without using PEAR

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RiceBallAttack
Forum Newbie
Posts: 1
Joined: Fri Nov 21, 2008 11:35 pm

db.php without using PEAR

Post 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!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: db.php without using PEAR

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: db.php without using PEAR

Post 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.
Post Reply