Chapter 9 page 231

Hey guyz,

I am back again with a stupid question ;D

Page 231 from the book…i did the cnages and now everytime i whant to go and view a comment from a issue/project i get and error like this one

[html]

CException

Property "IssueController._model" is not defined.

C:\xampp\htdocs\licenta\protected\controllers\IssueController.php(193)

181 Yii::app()->user->setFlash(‘commentSubmitted’, “Your comment has been added.”);

182 }

183 }

184 return $comment;

185 }

186 /**

187 * Returns the data model based on the primary key given in the GET variable.

188 * If the data model is not found, an HTTP exception will be raised.

189 * @param integer the ID of the model to be loaded

190 */

191 public function loadModel($withComments=false)

192 {

193 if($this->_model===null)

194 {

195 if(isset($_GET[‘id’]))

196 {

197 if($withComments)

198 {

199 $this->_model=Issue::model()->with(array(

200 ‘comments’=>array(‘with’=>‘author’)))->findbyPk($_GET[‘id’]);

201 }

202 }

203 else

204 {

205 $this->_model=Issue::model()->findbyPk($_GET[‘id’]);

[/html]

Can someone please he,p me…i am stuck here for 1 day already and is killing my sleep :(

The book’s text doesn’t mention it but at this point you must also declare a private $_model variable at the top of the controller class. The code accompanying the book has it:


<?php


class IssueController extends Controller

{

	/**

	 * @var string the default layout for the views. Defaults to 'column2', meaning

	 * using two-column layout. See 'protected/views/layouts/column2.php'.

	 */

	public $layout='column2';


	/**

	 * @var CActiveRecord the currently loaded data model instance.

	 */

	private $_model;

	

	/**

	 * @var private property containing the associated Project model instance.

	 */

	private $_project = null; 

	


	/**

	 * @return array action filters

	 */

	public function filters()

	{

...



Whenever you are stuck with your code not working, try the code that comes with the book. If that works but yours doesn’t, look for the differences.

thx a lot mate…you saved me…i need to be read more the trace so i understand better the code i copy paste:D

really saved !