Show
Ignore:
Timestamp:
09/27/08 17:43:42 (3 months ago)
Author:
mikeseth
Message:

clear up confusion with the base model

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • documentation/trunk/topics/creating-models.dita

    r2723 r2951  
    2929    methods: one to return the contents of the front page (a list of the most 
    3030    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 
     35Module name: <userinput>Public</userinput> 
    3336 
    3437Model 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 
    4049    is <apiname>findPostById</apiname>, which accepts an ID parameter 
    4150    and returns corresponding post data as a single dimensional 
     
    4554    posts themselves. Both methods obtain the connection from Agavi's 
    4655    database manager, perform an SQL query against it and return the 
    47     results.</p><p><note type="important">We will soon discover that 
    48     we need more than one Model to handle posts!</note></p><p>As we 
    49     already have some dummy data in the database, we can now proceed 
    50     to make working pages that utilize our new Model.</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> 
    5160  </body> 
    5261</topic>