Active Record problem

Hello all,

I'm feeling stupid, but I have a strange AR problem:

I have 2 tables: Album and Photo

The relation of Album to Photo is a

'photos'=>array(self::HAS_MANY, 'Photo', 'PhAlId'),

When I do the following: ($_GET['id'] has a value)



$album=Album::model()


        ->with(array('photos'=>array('condition' => 'PhRecStatus=2')))


->findAllByPk($_GET['id']);


$this->render('show',array('album'=>$album));


and in my view (for test):

foreach($album as $photo)

{

  print '1<Br/>';

}

my output is 1 (one) number 1.

When I run the query in my database, it gives me four records back. I also cannot echo $photo->photos->PhFileName (and PhFileName is a valid column name in table Photo) inside the foreach loop. I get an error:  Trying to get property of non-object.

Can anyone help me with this?

Thnx

I think what you want to do is retrieving the specified album and then displaying the photos in it, right?

If so, you should call findByPk($_GET['id']), and in the view you should iterate through photos, not album:



foreach($album->photos as $photo)...


That was the solution!

Thanks a lot for your quick reply!