If I have a database class, and pass an instance of that class to the constructors of other classes, will it still only be using one connection or will it create as many connections as constructors I pass it to?
1 Answer
Generally speaking, an object that gets passed to a function or is assigned to a variable (without using clone) will increase the reference count but will not create another instance.
If an object is cloned, all properties are copied into a new object; scalar properties will get duplicated, other properties (objects, resources) will instead have an increased reference count.
Conclusion
Assuming you have created a single instance of your database class and the database connection is created once inside the constructor and stored inside a property, passing it around will not cause multiple connections to be opened.