Basically what I wanna do is show all Items and which Levels they belong to. (eg. Item "testarossa" is in "cars"->"supercars"->"ferrari")
I declared my sql-statement in the model and it works.
My Grid displays valid data in every row and column, but when it comes to level2 and 1, the relations aren’t displayed correctly. I think I have a problem with the column data and the table hierarchy.
Did you try create four models and declare relations inside them?
You can create these models and declare for each BELONG_TO relation, finally you’ll get expressions in your grid look like that ‘level1.level2.level3.descr’
Thank you for your response! Inside each model file there is a relations() containing the BELONGS_TO. This was generated by GiiModel Creator. Anyway… how do I change my GRID, so that the column value for Level2 and Level1 is displayed correctly?
It seems that the linking of the data (with keys) wont work correctly…
Here are my two (SAME) SQL-Statements:
$criteria->join .=' JOIN ebene3 as e3 ON t.e3id = e3.e3id JOIN ebene2 as e2 ON e2.e2id = e3.e2id JOIN ebene1 as e1 ON e1.e1id = e2.e1id';
//$criteria->join .=' INNER JOIN ebene2 as e2 ON e2.e2id = e3.e2id';
//$criteria->join .=' INNER JOIN ebene1 as e1 ON e1.e1id = e2.e1id';
$criteria->together = true;
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
and
$sql = 'SELECT e1.e1bez, e2.e2bez, e3.e3bez, f.fbez FROM Frage f
INNER JOIN ebene3 e3 on e3.e3id=f.e3id
INNER JOIN ebene2 e2 on e2.e2id=e3.e2id
INNER JOIN ebene1 e1 on e1.e1id=e2.e1id;';
return new CSqlDataProvider($sql, array(
'keyField' => 'fbez'
));