I've had some problems joining two tables with CActiveDataProvider
The tables are: question(id,description) , questionInFeedback(feedbackId,questionId)
and the relations :
feedback=>
'questionInFeedbacks' => array(self::HAS_MANY,'QuestionInFeedback','feedbackId'),
question=>
'questionInFeedbacks' => array(self::HAS_MANY,'QuestionInFeedback','questionId'),
questionInFeedback=>
'feedback' => array(self::BELONGS_TO, 'Feedback', 'feedbackId'),
'question' => array(self::BELONGS_TO, 'Question', 'questionId'),
if I could use SQL then i'd use
SELECT q.id
FROM questionInFeedback AS qf,Question AS q
WHERE qf.question_id=q.id
I need these Questions ID to display in feedback view the question which are related to the feedback.
protected/controllers/feedbackController:
$issueDataProvider=new CActiveDataProvider('Question', array(
'criteria'=>array(
'condition'=>'',
'params'=>array(':questionId'=>$this->loadModel($id)->id),
Thanks for the help :)
EDIT : Yii is giving me the following error;
"Invalid argument supplied for foreach()", with line 826 being highlighted.
{
815 // determine the primary key value
816 if(is_string($this->_pkAlias)) // single key
817 {
818 if(isset($row[$this->_pkAlias]))
819 $pk=$row[$this->_pkAlias];
820 else // no matching related objects
821 return null;
822 }
823 else // is_array, composite key
824 {
825 $pk=array();
826 foreach($this->_pkAlias as $name=>$alias)
827 {
828 if(isset($row[$alias]))
829 $pk[$name]=$row[$alias];
830 else // no matching related objects
831 return null;
832 }
833 $pk=serialize($pk);
834 }
835
836 // retrieve or populate the record according to the primary key value
837 if(isset($this->records[$pk]))
838 $record=$this->records[$pk];