Search the Community
Showing results for tags 'instance'.
-
Larry, on page 150 of the YiiBook2 (latest version), you write that the following code is "verbose, redundant, and illogical": $model = new Page(); $model = $model->findOne($id); Instead of creating an instance of the Page class, as shown above, you say we should use a static class instance (or static method?), like this: if (($model = Page::findOne($id)) !== null) { return $model; etc. I don't understand why the first example is "verbose, redundant, and illogical", and why the second example is preferred. Can you please explain this? Thanks.
-
- static class instance
- static class
-
(and 5 more)
Tagged with:
-
Version 0.5 Two questions about page 115. 1. Quoting from the book: "<?php $this->pageTitle = Yii::app()->name . '::' . $model->title; ?>" Why are there two colons before $model->title ? I assume they will appear literally, but maybe they function as code -- I'm not sure. 2. Quoting from the book again: "{TIP} Because the page title is set by assigning a value to the controller instance, it can also be set within the controller action, if you’d rather." This sentence is saying 2 things, neither of which I understand. Larry, can you please break this down and provide an example? Thanks.