kopecsrk
(Dzumir)
1
Hello.
I have Join function:
public function getFormQuest() {
$select = Yii::app()->db->createCommand()
->select('pytanie')
->from('quest_open p')
->join('odp_open_form o', 'p.id=o.quest_open_id')
->where('form_id=' . $this->id . '')
->queryAll();
}
And in view :
<?php $model->getFormQuest();?>
How i can get foreach in view, where my question must by render.
sukunj
(Mendparasukunj27)
2
Hello.
You have to return the array then only you can get array in view and then using forwach loop u can retrive data.
your function shold be like this as follow:
public function getFormQuest() {
$select = Yii::app()->db->createCommand()
->select('pytanie')
->from('quest_open p')
->join('odp_open_form o', 'p.id=o.quest_open_id')
->where('form_id=' . $this->id . '')
->queryAll();
return $select;
}
And in view :
<?php
$model->getFormQuest();?>
How i can get foreach in view, where my question must by render.
[/quote]
kopecsrk
(Dzumir)
3
Now i do that, but in view doesn;t render my question.
But when i do that:
public function getFormQuest() {
$select = Yii::app()->db->createCommand()
->select('pytanie')
->from('quest_open p')
->join('odp_open_form o', 'p.id=o.quest_open_id')
->where('form_id=' . $this->id . '')
->queryAll();
var_dump($select);
}
I get in view:
array (size=3)
0 =>
array (size=1)
'question' => string 'question 1?' (length=11)
1 =>
array (size=1)
'question' => string 'question 2?' (length=11)
2 =>
array (size=1)
'question' => string 'question 3?' (length=11)
sukunj
(Mendparasukunj27)
4
public function getFormQuest() {
$select = Yii::app()->db->createCommand()
->select('pytanie')
->from('quest_open p')
->join('odp_open_form o', 'p.id=o.quest_open_id')
->where('form_id=' . $this->id . '')
->queryAll();
return $select;
}
and in the view file
<?php
$data = $model->getFormQuest();
print_r($data);exit;
?>
This will 100% work…I have tried …
kopecsrk
(Dzumir)
5
yeah man
its works
Sorry .
I now have that:
Question 1
replies for question 1
replies for question 2
replies for question 3
Question 2
replies for question 1
replies for question 2
replies for question 3
Question 3
replies for question 1
replies for question 2
replies for question 3
I need :
Question 1
replies for question 1
Question 2
replies for question 2
Question 3
replies for question 3