MySQL Forums
Forum List  »  PHP

Keeping connection variable across functions
Posted by: Gugs Ntombela
Date: July 17, 2005 08:49AM

I'm currently developing an application in PHP where I store data in a MYSQL database. I made a database class which allows connection and other several operations such as query,etc.

Is there a way that I can keep a connection variable such that it is globally available across all functions such that I don't have to pass the connection variable to each and every function I call? an example is shown bellow.

I have a class db.

So I can say:
$connection = &new db("username","password","dbhost","dbname");

then for every function I call say display, I will have to say:

display($connection,..............);

So I've been doing this for every function I call.

Options: ReplyQuote


Subject
Written By
Posted
Keeping connection variable across functions
July 17, 2005 08:49AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.