title: should i upgrade this model to inheritance?
body: <p>I'm expanding my php and general coding knowledge by writing my own 'simple' CMS system.</p>
  
  <p>My database structure follows:</p>
  
  <pre><code>USERS --&lt; WEBSITES --&lt; PAGES
  </code></pre>
  
  <p>In my logic, I have three classes, a <code>User</code>, <code>Website</code> and <code>Page</code> class. <strong>NOT INHERITED</strong></p>
  
  <p>The <code>User</code> class has all the attributes from the <code>USER TABLE</code> plus a <code>$_website</code> attribute,</p>
  
  <p>The <code>Website</code> class has all the attributes of the <code>WEBSITE TABLE</code> plus an ARRAY of <code>Page</code> objects</p>
  
  <p>The way I have decided to work this is, on page load, these classes will be created and filled with the database data.</p>
  
  <p>So then in the html I can echo out results simply by calling the class like so:</p>
  
  <pre><code>$USER -&gt; name;
  $USER -&gt; website -&gt; get_pages();
  $USER -&gt; website -&gt; pages[0] -&gt; get_header();
  </code></pre>
  
  <hr>
  
  <p>I Realised that these classes could be inherited, so <code>Page</code> inherits <code>Website</code> and <code>Website</code> inherits <code>User</code></p>
  
  <p>But if I do it that way, then I'll instantiate the <code>Page</code> class like:</p>
  
  <pre><code>$PAGES = array(); 
  $PAGES[] = new Page( $constructor_data_to_construct_user_website_and_page );
  </code></pre>
  
  <p>Now IF I do it this way, the object <code>$PAGES[0]</code> will have all the info to do with that page, and all the info to do with the Website (first parent),
  and all the info to do with the User ( second parent )</p>
  
  <p>If i then create another <code>Page</code>, i'm just <strong>copying</strong> the same <code>User</code> and <code>Website</code> details <strong><em>Yes</em></strong>?</p>
  
  <p>So if i were to <code>var_dump $PAGES[0]</code> id get ALL the info to do with <code>USER,</code> <code>WEBSITE</code> and <code>PAGE</code></p>
  
  <p>If i were to <code>var_dump $PAGES[1]</code> id get ALL THE SAME information for <code>USERS</code> AND <code>WEBSITE</code>, but just the different <code>Page</code> data.</p>
  
  <p><em>So inheritance, is causing unnecessary copying of the User and Website objects</em></p>
  
  <p>Because I could essentially do: </p>
  
  <pre><code>$PAGES[0] -&gt; username // username is a property of the Users class
  $PAGES[1] -&gt; username
  </code></pre>
  
  <p>both would return EXACTLY the same value.</p>
  
  <p>surely this is bad because data is being unnecessarily copied!</p>
  
  <p><em><strong>Is This Correct?</em></strong></p>
  
  <p>Or is this question a load of rubbish and this isn't the kind of situation <code>inheritance</code> is used?</p>