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
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
Jump to PostI'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.
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.
You're trying to visit a URL that doesn't currently exist on the web. Most likely, a member posted a link a long time ago to a web page that has since been removed. It's also possible that there was a typo when posting the URL. We redirect you to this notice instead of stripping out the link to preserve the integrity of the post.