I am writing some code that will have several functions. I need the functions to have my database connection, is there a way that I can include the connection variable in all functions?


Recommended Answers

All 3 Replies

I'd suggest writing a class that creates a connection to your database and then each method/function within your class can access the database connection.

Any example of how to do that?

Search this forum, lots of samples.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.