How can one class use another?
Posted: Fri Feb 03, 2006 2:18 pm
I wrote a mySQL class to handle queries and output results a certain way. Then I have 5 other classes that each do different things but all need to use the mySQL class. I tried to do it like this, but it didn't work:
Yea... that doesn't work. I've been googling for over an hour now. I must be using the wrong keywords. I found "class1 extends class2", but I'm not sure if that's what I need, and if it is, how do I do it? Do I modify each class declaration to look like " class OtherClass extends mySQLClass ", how would I call the mySQLClass methods?
I know this is very newb, and I'm asking many questions. Thanks in advance for your patience.
Code: Select all
class OtherClass {
var $db = new mySQLClass;
function getResults($query) {
$db->Query($query);
}
}I know this is very newb, and I'm asking many questions. Thanks in advance for your patience.