Analyzing the Yii error stack trace
When an error occurs, Yii can display the error stack trace along with the error. A stack trace is especially helpful when we need to know what really caused an error rather than just the fact that an error occurred.
Getting ready
Set up a fresh Yii application by using
yiic webappas described in the official guide.Configure a database and import the following SQL:
CREATE TABLE `article` ( `alias` varchar(255) NOT NULL, `title` varchar(255) NOT NULL, `text` text NOT NULL, PRIMARY KEY (`alias`) );
Generate an
Articlemodel using Gii.
How to do it...
Carry out the following steps:
Now we will need to create some code to work with. Create
protected/controllers/ErrorController.phpas follows:<?php class ErrorController extends CController { public function actionIndex() { $articles = $this->getModels('php'); foreach($articles as $article) { echo $article->title; echo "<br />"; } } private...