c_pattle Posted March 21, 2011 Share Posted March 21, 2011 I have a class and a lot of the function in the class require a connection to a MySQL database. At the moment I am using the "__construct()" to connect to the database each time a new instance of the classes is created. Is this the best way to do it or should I have a separate class for connection to the database? Just wanted to get an idea of what other people do. Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/231303-mysql-connection-in-classes/ Share on other sites More sharing options...
KevinM1 Posted March 21, 2011 Share Posted March 21, 2011 http://www.google.com/search?q=dependency+injection&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a Link to comment https://forums.phpfreaks.com/topic/231303-mysql-connection-in-classes/#findComment-1190480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.