[eluser]wowdezign[/eluser]
Code:
considering i’d make two queries one for the questions and another for the options
how can i pass the poll id into the displayOptions function, i must extract the id from the array $data[‘poll’] , how ?
$data[‘poll’] = $this->MPoll->displayPoll(); //
$data[‘options’] = $this->MPoll->displayOptions(????);
How about:
Code:
$data[‘poll’] = $this->MPoll->displayPoll();
$data[‘options’] = $this->MPoll->displayOptions($data['poll']->id);
Once you have the object stored in a variable, you can access its properties. In this case, $data is an array, the array key 'poll' refers to an object that has an id property. So, $data['poll']->id should work.
You have to be aware of what you are returning from your model. If it is an array, you'll need to do:
Code:
$data[‘poll’] = $this->MPoll->displayPoll();
$data[‘options’] = $this->MPoll->displayOptions($data['poll']['id']);
instead.