Arty Ziff Posted December 28, 2010 Share Posted December 28, 2010 How does one go about using one class inside another? For example, building a class that does some series of functions, and uses a db abstraction layer class in the process? Quote Link to comment https://forums.phpfreaks.com/topic/222793-using-a-db-abstraction-class-in-a-different-class/ Share on other sites More sharing options...
trq Posted December 28, 2010 Share Posted December 28, 2010 Your first need to ensure that the database abstraction implements an interface that the other class understands. Then, simply instantiate the database class, and pass it to the other class via either a purpose build method, or the __construct, making sure you use type hinting to enforce the correct interface. Quote Link to comment https://forums.phpfreaks.com/topic/222793-using-a-db-abstraction-class-in-a-different-class/#findComment-1152036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.