Changeset 2951 for documentation/trunk/topics/creating-models.dita
- Timestamp:
- 09/27/08 17:43:42 (3 months ago)
- Files:
-
- 1 modified
-
documentation/trunk/topics/creating-models.dita (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
documentation/trunk/topics/creating-models.dita
r2723 r2951 29 29 methods: one to return the contents of the front page (a list of the most 30 30 recent posts) and one to find a specific post given its ID. To do this, 31 you need to create a new Model! The project configuration system eases 32 your job immensely:</p><p><screen>bloggie$ <userinput>agavi project-model-create</userinput> 31 you need to create a new Model. The project configuration system eases 32 your job immensely:</p><p> 33 <screen>bloggie$ <userinput>agavi model-create</userinput> 34 35 Module name: <userinput>Public</userinput> 33 36 34 37 Model name: <userinput>Posts</userinput> 35 [copy] Copying 1 file to /home/nfontes/bloggie/app/models</screen>You now 36 have an empty Posts Model class ready to be populated with application 37 logic:</p> 38 <codeblock conref="examples.xml#stage2-posts-model" class="php"/> 39 <p>The Posts Model contains two very simple methods. The first 38 [copy] Copying 1 file to [...]/app/modules/Public/models</screen> 39 </p> 40 <p>You now have an empty Posts Model class ready to be populated 41 with application logic:</p> 42 <codeblock conref="examples.xml#stage2-posts-model" class="php"/> 43 <p>Note that in the base Model class for Bloggie 44 (<filepath>app/lib/models/BlogBaseModel.class.php</filepath>) we 45 have a <apiname>getPdo()</apiname> method which we presume all of our future models 46 would want to use:</p> 47 <codeblock conref="examples.xml#stage2-base-model" class="php"/> 48 <p>The Posts Model contains two very simple methods. The first 40 49 is <apiname>findPostById</apiname>, which accepts an ID parameter 41 50 and returns corresponding post data as a single dimensional … … 45 54 posts themselves. Both methods obtain the connection from Agavi's 46 55 database manager, perform an SQL query against it and return the 47 results.</p> <p><note type="important">We will soon discover that48 we need more than one Model to handle posts!</note></p><p>As we49 already have some dummy data in the database, we can now proceed50 to make working pages that utilize our newModel.</p></section>56 results.</p> 57 <p>As we already have some dummy data in the database, we can now 58 proceed to make working pages that utilize our new 59 Model.</p></section> 51 60 </body> 52 61 </topic>

