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?

Thanks

Recommended Answers

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.

Jump to Post

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.