Cách Dùng Whoever, Whichever, Whatever, Whenever, Wherever Và ...

yii\base\ErrorException: Trying to get property of non-object in /var/www/resource/viettalk.net/frontend/controllers/PostController.php:42 Stack trace: #0 /var/www/resource/viettalk.net/frontend/controllers/PostController.php(42): yii\base\ErrorHandler->handleError(8, 'Trying to get p...', '/var/www/resour...', 42, Array) #1 [internal function]: frontend\controllers\PostController->actionDetail('333') #2 /var/www/resource/viettalk.net/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array) #3 /var/www/resource/viettalk.net/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array) #4 /var/www/resource/viettalk.net/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('detail', Array) #5 /var/www/resource/viettalk.net/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('post/detail', Array) #6 /var/www/resource/viettalk.net/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request)) #7 /var/www/resource/viettalk.net/frontend/web/index.php(43): yii\base\Application->run() #8 {main} Copied! Copy Stacktrace Search Stackoverflow Search Google Error PHP Notice – yii\base\ErrorException

Trying to get property of non-object

  • 1. in /var/www/resource/viettalk.net/frontend/controllers/PostController.php at line 42 33343536373839404142434445464748495051 ->all(); return $this->render('index', ['posts' => $models, 'pages' => $pages]); } /** * */ public function actionDetail($id) { $post = Post::findOne(['post_id'=> $id]); $this->title = $post->title; return $this->render('detail', ['post' => $post]); } public function actionGuide() { $this->page = "page-guide"; $list= Post::listStatus(); $this->title = $list[Post::STATUS_GUIDE]; $post= Post::find()->andWhere(['status'=>Post::STATUS_GUIDE])->all(); return $this->render('guide',['guides'=>$post]);
  • 2. in /var/www/resource/viettalk.net/frontend/controllers/PostController.php at line 42 – yii\base\ErrorHandler::handleError(8, 'Trying to get property of non-ob...', '/var/www/resource/viettalk.net/f...', 42, ...) 36373839404142434445464748 } /** * */ public function actionDetail($id) { $post = Post::findOne(['post_id'=> $id]); $this->title = $post->title; return $this->render('detail', ['post' => $post]); } public function actionGuide() { $this->page = "page-guide"; $list= Post::listStatus(); $this->title = $list[Post::STATUS_GUIDE];
  • 3. frontend\controllers\PostController::actionDetail('333')
  • 4. in /var/www/resource/viettalk.net/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([frontend\controllers\PostController, 'actionDetail'], ['333']) 515253545556575859 $args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
  • 5. in /var/www/resource/viettalk.net/vendor/yiisoft/yii2/base/Controller.php at line 157 – yii\base\InlineAction::runWithParams(['id' => '333', 'title' => 'cach-dung-whoever-whichever-what...']) 151152153154155156157158159160161162163 } $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
  • 6. in /var/www/resource/viettalk.net/vendor/yiisoft/yii2/base/Module.php at line 528 – yii\base\Controller::runAction('detail', ['id' => '333', 'title' => 'cach-dung-whoever-whichever-what...']) 522523524525526527528529530531532533534 $parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
  • 7. in /var/www/resource/viettalk.net/vendor/yiisoft/yii2/web/Application.php at line 103 – yii\base\Module::runAction('post/detail', ['id' => '333', 'title' => 'cach-dung-whoever-whichever-what...']) 979899100101102103104105106107108109 $params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
  • 8. in /var/www/resource/viettalk.net/vendor/yiisoft/yii2/base/Application.php at line 386 – yii\web\Application::handleRequest(yii\web\Request) 380381382383384385386387388389390391392 { try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
  • 9. in /var/www/resource/viettalk.net/frontend/web/index.php at line 43 – yii\base\Application::run() 37383940414243 require(__DIR__ . '/../config/main-local.php') ); //echo '<pre>'; var_dump($config['modules']); echo '<pre/>'; //die; $application = new yii\web\Application($config); $application->run();
$_GET = [ 'id' => '333', 'title' => 'cach-dung-whoever-whichever-whatever-whenever-wherever-va-however', ]; $_SESSION = [ '__flash' => [], 'language' => 'en', ]; Yii Framework

2024-11-25, 12:10:01

Apache/2.4.18 (Ubuntu)

Yii Framework/2.0.15

Từ khóa » Cách Dùng Của Whenever