ridiculous Posted March 14, 2009 Share Posted March 14, 2009 [1] I'm trying to make a PDO connection into an object and pass the connection to outside classes. [2] I can do this when I put the PDO connection in a constructor but not when I put it in a public method. [3] I have the code pasted here : http://www.pastebin.ca/1360597 [4] I am monitoring this thread closely so please ask away if I can clarify anything. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/149367-oop-packing-db-connection-in-object/ Share on other sites More sharing options...
TonyCastle Posted March 14, 2009 Share Posted March 14, 2009 Hi, if I'm missing something I apologise in advance I only started looking at OOP myself this weekend but it seems that in the example that doesn't work your class doesn't have a constructor or extend a class that does have a constructor and neither is it abstract, how do you instantiate it? Link to comment https://forums.phpfreaks.com/topic/149367-oop-packing-db-connection-in-object/#findComment-784577 Share on other sites More sharing options...
corbin Posted March 14, 2009 Share Posted March 14, 2009 connect_1 is the return value of connect() which does not return anything. So you're print_r()ing a null value. Link to comment https://forums.phpfreaks.com/topic/149367-oop-packing-db-connection-in-object/#findComment-784612 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.