Error

Call to a member function updateByPk() on null

/home/jpc/public_html/modules/vacancy/controllers/SiteController.php(262)

250     public function actionView($id)
251     {
252         $action = explode('/', strtolower(Yii::app()->request->requestUri));
253         $count = preg_match("/^[a-zA-Z0-9?_=&+\/-]+$/", $action[5]);
254         if ($action[5] != null) {
255             if ($count == 0) {
256                 $this->redirect(Yii::app()->controller->createUrl('site/index'));
257             }
258         }
259         $id = (int) $id;
260         $model = CcnEmployerVacancy::model()->findByPk($id);
261         $popularityScore = ((60 / 100 * $model->total_apply) + (40 / 100 * ($model->hits + 1)));
262         $model->updateByPk($id, ['hits' => ($model->hits + 1), 'popularity' => $popularityScore]);
263         $employer = CcnEmployerData::model()->find([
264             'condition' => 'swt_users_id = :uid',
265             'params' => [':uid' => $model->swt_users_id],
266         ]);
267 
268         $this->pageTitle = 'Lowongan ' . $model->position_name . ' - ' . $model->employer_data->name;
269         $this->pageDescription = $model->meta_desc;
270         $this->pageMeta = $model->meta_keyword;
271 
272         if ($model->style == 1) {
273             //$render = 'front_view_single';
274             $render = WebOption::isThemeResponsif() ? 'front_view_single_responsif' : 'front_view_single';

Stack Trace

#14
+
 /home/jpc/public_html/web/index.php(52): CApplication->run()
47 define('WEB_ROOT', Yii::getPathOfAlias('webroot'));
48 define('APP_ROOT', Yii::getPathOfAlias('application'));
49 
50 require_once (APP_ROOT . '/components/helpers.php');
51 
52 $app->run();
2024-03-29 15:25:10 Apache/2.4.56 (Unix) OpenSSL/1.0.2k-fips Yii Framework/1.1.28