title: Multiple Tables for a single Model using Zend_Model_Mappers and Zend_Db_Table_Abstract
body: <p>not sure if I'm asking too many questions on stackoverflow lately but I feel that the Zend Framework documentation is appalling. It seems like the examples are very vague and nothing like what is used in the real world. They encourage use of framework for tidy and organised code and then don't mention how it should be followed :D</p>
  
  <p>So anyway! In the old application that I'm currently migrating across to Zend, I'd have a function called register like: </p>
  
  <pre><code>function register($username, $password, $email, $etc) {
      // Do stuff
      // Insert $email and other stuff into `user_profile` table
      // Insert $username and $password into the `user` table
  }
  </code></pre>
  
  <p>But now with Zend... I've been following their Guestbook tutorial for getting started and I have the following models: <code>User</code>, <code>UserMapper</code>. 
  And I have DbTables for every single table in my database like so: <code>User</code>, <code>UserProfile</code>.</p>
  
  <p>So I like the functionality of when you register, you build up a User object and then call <code>save</code> on the mapper which writes the object to the database but the thing is, some of those user pieces go into the user profile table. The example on the guestbook application is that within UserMapper you only pull in the one table (User) and write to that... well I mean I could just do something like:</p>
  
  <pre><code>// Insert or Update data to user table
  $this-&gt;getDbTable()-&gt;insert($user_data);
  // Insert or Update User Profile data
  $this-&gt;setDbTable('UserProfile');
  $this-&gt;getDbTable()-&gt;insert($user_profile);
  </code></pre>
  
  <p>But that just seems a bit.. hacky. What is the actual recommended way of dealing with multiple tables? </p>
  
  <p>Also, if I have custom queries... am I meant to put them into the created <code>DbTable</code> class or into the <code>UserMapper</code> class? I'm not really seeing what extending the DbTable is actually for. All the guide says is to do it and it doesn't really explain the benefits/reason/uses as to why you're doing it.</p>
  
  <p>Thanks, Dom</p>