When you access the relation of the model, like $model->relationName, you gather access to the relationName model relations too, so things like $model->relationName->SomeRelationInRelationName->name is perfectly valid, as long as the relation "relationName and SomeRelationInRelationName" returns only a single instance of the related model.
In case these returns multiple instances(arrays), then you’ll have to loop through them.
if (isset($_POST["oras"])){
$orase = Orase::model()->findAll(array("condition"=>"nume_oras like '%".$_POST["oras"]."%'","order"=>"id_oras"));
//$orase = Orase::model()->findByPk(5);
foreach ($orase as $orase_gasite):
echo "Regiunea:".$orase_gasite->provincie->regiune->nume_regiune." Provincia:".$orase_gasite->provincie->nume_provincie." Oras:".$orase_gasite->nume_oras."<br>";
endforeach;
}
But what i am not sure, is if i did the search correctly, and if there is another way to perform this search.
One field where the user inserts the city he is looking for, and then the search form returns the results.
I have created on the view page a form with the action in index (the form is on the front page), but i am sure there is a better way than hardcoding the form in that file.