Display Non-Related Db Content

I have a model without a db table used to display information that is stored in a session.

I am able to display the content in the session which was loaded from a given table using


  $ids = Yii::app()->storedData->getIds();

    foreach($ids as $id) {

    echo 'ID '.$id .'<br />'; 

    } 

Instead of displaying the Ids I would rather display information from a related table of the table from which this info was loaded into the session.

To help explain what I am after, given:

I have ModelC to display session data that is loaded from TableA. Currently with the code above the returned values are TableAId. I would rather display TableB:Description instead. How can I go about doing this without just loading that Description value into the session data too?

In the above code I can retrieve a variable in the session in ModelC by using


$ids = Yii::app()->storedData->getIds();

say this gives me 48 which is TableAId. Instead of getting 48 I want to return the related description which is stored in TableB.

Do a findByPk() for each ID and echo the description.

Pseudocode:




foreach $ids as $id

{

  $model=Model::findByPk($id);

  echo $model->description;

}



When I try to use your code example I get "ModelCController does not have a method named "getTableAlias"."

I am not sure what is causing this or how to clear it up. Any ideas?

you got it wrong, it suppose to be


foreach $ids as $id

{

  $model=Model::model()->findByPk($id);

  echo $model->description;

}

findByPk is not a static method

Thats why I said pseudocode :)

Thanks for the correction.

Ok by changing from findByPk to findByAttributes in the above code (as was pointed out to me on SO) I have got what I need. Thanks you two for the help.