Error

Call to a member function getAttributes() on null

/var/www/u1669848/data/www/dsb0058.ru/protected/models/Catalog.php(167)

155          return $result;
156     }
157 
158     /**
159      * Gets the parent category of a given category
160      *
161      * @param $categoryId if of starting category
162      * @return DbTable_Catalog_CategoryRow
163      */
164     public function getParentById($categoryId)
165     {
166         $model = self::model();
167         $categoryRow = $model->findbyPk($categoryId)->getAttributes();
168         $query = array('order'=>'lft DESC');
169         $criteria=new CDbCriteria($query); 
170         $criteria->addCondition('lft<=' . $categoryRow['lft']);
171         $criteria->addCondition('rgt>=' . $categoryRow['rgt']);
172         $model->setDbCriteria($criteria);
173         $result = $model->findAll();
174         if(count($result) == 1) {
175             return $result[0];
176         }
177         return $result[1];
178     }
179     

Stack Trace

#0
+
 /var/www/u1669848/data/www/dsb0058.ru/protected/controllers/CatalogController.php(24): Catalog->getParentById("99")
19         //$this->layout='column_detail';
20         $id = intval($id);
21         $model = Product::model()->getProduct($id);
22         if($model===null)
23             throw new CHttpException(404,I18n::t('The requested page does not exist.'));
24         $cata = Catalog::model()->getParentById($model->typeid);
25         $thiscat = Catalog::model()->getById($model->typeid);
26         $model->typename = $thiscat['name'];
27         
28         //���µ������
29         $arc = Archives::model()->findByPk($id);
#10
+
 /var/www/u1669848/data/www/dsb0058.ru/index.php(13): CApplication->run()
08 
09 // remove the following line when in production mode
10 defined('YII_DEBUG') or define('YII_DEBUG',true);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();
2024-03-28 15:18:17 Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 Phusion_Passenger/5.3.7 Yii Framework/1.1.10