PHP notice

Trying to get property of non-object

/home/maymoc12nv/public_html/frontend/controllers/Danh_mucController.php(61)

49 
50     public function actionView($id)
51     {
52 
53         $page = isset($_GET['page']) && preg_match("/^\d+$/", $_GET['page']) ? $_GET['page'] : 0;
54         $page = $page > 0 ? $page - 1 : 0;
55         $pager = array();
56         $page_size = 9;
57 
58         $codeName = isset($id) ? $id : '';
59         $category = Category::model()->findByAttributes(array('title_code' => $codeName));
60         $criteria = new CDbCriteria();
61         $criteria->compare('category_id', $category->id);
62         $totalProducts = Product::model()->findAll($criteria);
63         $criteria->limit = $page_size;
64         $criteria->offset = $page_size * $page;
65         $criteria->order = 'create_date DESC';
66         $products = Product::model()->findAll($criteria);
67 
68         $total_result = count($totalProducts);
69         $total_page = ($total_result - ($total_result % $page_size))/$page_size + (($total_result % $page_size ===0)?0:1);
70         $a = array('page_number'=> $page, 'page_size'=>8, 'total_result'=>$total_result, 'total_page'=>$total_page);
71         foreach (array('total_result', 'page_number', 'page_size', 'total_page') as $e) {
72             if (array_key_exists($e, $a))
73                 $pager[$e] = $a[$e];

Stack Trace

#12
+
 /home/maymoc12nv/public_html/common/components/WebApplication.php(34): CWebApplication->runController("danh_muc/view")
29      * that Apache polls its processes to see if they're alive. This function causes
30      * Yii to respond without logging errors.
31      */
32     public function runController($route) {
33         try {
34             parent::runController($route);
35         } catch (CHttpException $e) {
36             if (@$_SERVER['REQUEST_METHOD'] == 'OPTIONS' && @$_SERVER['REQUEST_URI'] == '*') {
37                 Yii::app()->end('Hello, friend!');
38             } else
39                 throw $e;
#15
+
 /home/maymoc12nv/public_html/index.php(22): CApplication->run()
17 
18 require_once($yii);
19 require_once($rootDir.'/common/components/WebApplication.php');
20 $app = Yii::createApplication('WebApplication', require($config));
21 
22 $app->run();
2024-03-19 14:44:45 LiteSpeed Yii Framework/1.1.14