PHP notice

Trying to get property of non-object

/home/admin/web/samreab.uz/public_html/protected/views/site/albums.php(27)

15 
16 <div class="row">
17     <?php
18     $albums = Albums::model()->findAll();
19     ?>
20     <?php
21         foreach ($albums as $al):
22             $ph = Photo::model()->findByAttributes(array('album_id'=>$al->id));
23         ?>
24         <div class="col-sm-6 col-md-3">
25             <div class="thumbnail">
26                 <a class="image-hover" href="<?php echo Yii::app()->createUrl('/site/photos', array('id' => $al->id))?>">
27                     <img class="img-responsive" src="<?php echo Yii::app()->baseUrl; ?>/images/photos/thumbs/<?php echo $ph->image;?>" alt="" />
28                 </a>
29                 <div class="caption">
30                     <h5>
31                         <?php echo CHtml::link(Albums::album_name($al->id),array('/site/photos/', 'id'=>$al->id)) ?>
32                     </h5>
33                 </div>
34             </div>
35         </div>
36     <?php
37         endforeach;
38     ?>
39 </div>

Stack Trace

#4
+
 /home/admin/web/samreab.uz/public_html/protected/controllers/SiteController.php(48): CController->render("albums")
43     public function actionAlbums()
44     {
45         $this->layout = "/layouts/column4";
46         // renders the view file 'protected/views/site/index.php'
47         // using the default layout 'protected/views/layouts/main.php'
48         $this->render('albums');
49     }
50 
51     public function actionPhotos($id)
52     {
53         $this->layout = "/layouts/column4";
#12
+
 /home/admin/web/samreab.uz/public_html/index.php(13): CApplication->run()
08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();
2024-03-29 18:06:50 Apache/2.4.18 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/1.0.2g Yii Framework/1.1.17