I am quite stuck on an issue. I read the doc and did not understand.
I have the following database:
Table :
cv_langue (for each language)
-->id_langue (primary key, auto inc)
-->title
cv_categorie (for each categorie)
-->id_cv_categorie (primary key, auto inc)
-->id_langue (refer to table cv_langue and id_langue)
-->title
cv_sub_categorie (for each sub categorie)
-->id_sub_categorie (primary key, auto inc)
-->id_cv_categorie (refer to table cv_categorie and id_cv_categorie)
-->title
cv_texte (for each data)
-->id_cv_texte
-->id_cv_categorie (refer to table cv_categorie and id_cv_categorie)
-->id_cv_sub_categorie (refer to table cv_sub_categorie and id_cv_sous_categorie)
-->id_cv_langue (refer to table cv_langue and id_langue)
-->texte
I set up the Relation between each other. What I am trying to do is to browse each language, and all sub categorie in categorie and finally display the data.
So I basically done :
$cv_texte = new cv_texte;
$List = cv_texte::model()->findAll();
But I am stuck with : How to browse the array correctly to do that?
You may add ORDER clause to sort them by category, subcategory and language. Then use a single for-loop to traverse the data. You will need to do grouping in PHP. However, if the sorting is done as suggested, this shouldn't be a big problem.
If you still want to use nested loops, you will need to perform a query for cv_texte at the innermost loop using the current category, subcateory and language.