I’ve been trying to change my programming style from procedure/function to OOP, and so far so good. However, there is some concept about OO that I’m not quite understand how to do it.
I have no problem coding classes handle data from 1 table, but not with multiple tables. I don’t know how should I make a class to deal with it.
What I have now is something like:
[CODE]
class A{
function getData(){
return $this->result[“field1”];
}
function getData2(){
return $this->result[“field2”];
}
}
class B{
function getData3(){
return $this->result[“B_field1”];
}
How should I make a class if I want to pull data from table A join with table B? Should I write a new class (like A_? and rewrite all of the function to retrieve all of those fields? or are there any other ways?
What I have thought is creating A and B object in a new class and passing value to both of them to retrieve data, but it’s kind of too many operation. Instead of using a single query (select * from A, B where A.Bid=B.Bid), it would be 2 separate queries…
Thanks for any suggestion ?