its call loadModel() method without parameter and cause a following error:
Error 500
Missing argument 1 for ProjectController::loadModel(), called in F:\wamp\www\trackstar\protected\controllers\ProjectController.php on line 56 and defined
i think the writer was made the mistake or me that was wrong? can anyone tell me what is the problem?
I check code that comes with book, and I think they have different solution:
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
*/
public function loadModel()
{
if($this->_model===null)
{
if(isset($_GET['id']))
$this->_model=Project::model()->findbyPk($_GET['id']);
if($this->_model===null)
throw new CHttpException(404,'The requested page does not exist.');
}
return $this->_model;
}
You can try to see if it works.
There are many errors in this book, however, I think it is still very good book to start with Yii framework and TDD.
You right Ivica, i have check the code resource belongs to the writer in github and it turns out the loadModel() has been overwrote. but i not remember the book tell me to do it in the previous pages
The reason why the code from the book doesn’t work for you is because the book was written using the older Yii 1.1.2 while you are using a newer version. The implementation of loadModel has changed in versions after version 1.1.2.