I can semi-conceptually get this, but I can’t wrap my head around the right way to do it.
Specifically, an object that needs to do the following…
class Question {
var $text;
var $filters = array();
var $banners = arrya(); //But this has to be within $filter somehow...
... //all getter and setter functions
}
Now I am going to query a database and get a bunch of data returned, say 4 columns.
QuestionText | Filter | Banner | Value
I want to end up with an object that looks like….
Object
Questions
->Question 1
->Text = Question One
->Filters
->Filter1
->Name = Ontario
Banners
Banner 1
->Name = Male
->Value = 20
Banner 2
->Name = Famales
->Value = 20
->Filter2
->Name = Quebec
Banners
Banners
Banner 1
->Name = Male
->Value = 20
Banner 2
->Name = Famales
->Value = 20
->Question 2
->Text = Question Two
->Filters
......
.....
....
...
Because I can only read from the database row by row, I need to find a way to add each new banner and value inside the Question / Filter combination. Eventually I want to spit it out as a table where each banner is a column.
Firstly, you will need three classes
Then you would start off by creating your questions and adding the filters and banners to them like so:
Hope that helps.