Search the Community
Showing results for tags 'method'.
-
Hi Larry, I have been working through the book and am at script 7.6 - rectangles5.cpp. Because of the constructor, I found that the setSize method is no longer needed as the constructor does the same job. I commented out all references to the setSize method and the application executes correctly in my Dev-C++ IDE. FYI, Cheers from Oz.
-
I'm not sure how the second part of this example is related to the first, and where it belongs. I am quoting from page 174 of YiiBook2: # models/Page.php public function getUser() { return $this->hasOne(User::className(), ['id' => 'user_id']); } This means you can fetch every page with every page author in one step: $pages = Page::find()->with('user')->all(); I'm guessing that with('user') calls the getUser method. Is that right? But in which file does the second part of the example belong? In the view file?
- 1 reply
-
- getuser
- with(user)
-
(and 4 more)
Tagged with:
-
First, thanks to both of you for writing the book and for how well the content is explained. However I'm having trouble understanding this statement on page 260: From what I can find via Google searches and tinkering with the pets4.cpp code, having a method in the derived class with the same name (different signature or not) as one in the base class hides the base class method, much like overriding a method seems to. Can you maybe explain that in a different way so it makes more sense to me? Thanks in advance!
-
When To Use A Property Vs A Method?
kamaboko posted a topic in Modern Javascript: Develop and Design
Hello, Is there a rule I should think of when deciding to use a property vs a method? Thanks, K -
Version 0.5 Loading a Single Model The following two examples work together. The second calls the first. I believe the purpose is to retrieve a record from a table. And I believe each occurrence of $id represents the primary key value of the particular record we want. My question is, how do these functions know which table to search in? page 136: public function loadModel($id) { $model = Page::model()->findByPk($id); if ($model===null) { throw new CHttpException(404, 'The requested page does not exist.'); } Page 139: public function actionView($id){ $this->render('view',array( 'model'=>$this->loadModel($id), )); }