title: mysql_fetch_object with specific class
body: <p>I developed an object-oriented guestbook and I have my Class <code>GuestBookEntry</code>:</p>
  
  <pre><code>class GuestBookEntry {
  protected $id;
  protected $entryDate;
  protected $authorName;
  protected $authorMail;  
  protected $entryText; 
  
  // getters, setters and specific functions are omitted
  }
  </code></pre>
  
  <p>I also have a <code>mysql</code> table with the same names as columns.</p>
  
  <p>Well, when I fetch guestbook entries, it seems to work, but it only displays the <code>ID</code> and the <code>Date</code>, which where returned by getters. The other things won't return to the template.</p>
  
  <p>The code looks like this:</p>
  
  <pre><code>public function showEntries() { 
      $query = mysql_query('SELECT * FROM dng_entries ORDER BY id DESC');     
      while($entry = @mysql_fetch_object($query, 'GuestBookEntry')) {
          if(empty($entry)) {
          echo '&lt;font color="white"&gt;Keine Eintr&amp;auml;ge vorhanden...&lt;/font&gt;';
          } else {    
          var_dump($entry);
          echo '&lt;table class="table table-bordered entryfield" align="right"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;td rowspan="2"&gt;'.$entry-&gt;getId().'&lt;/td&gt;
                          &lt;td width="20%"&gt;Datum:&lt;/td&gt;
                          &lt;td&gt;Name:&lt;/td&gt;
                          &lt;td&gt;Email:&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;'.$entry-&gt;getEntryDate().'&lt;/td&gt;
                          &lt;td&gt;'.$entry-&gt;getAuthorName().'&lt;/td&gt;
                          &lt;td&gt;&lt;a href="mailto:'.$entry-&gt;getAuthorMail().'"&gt;'.$entry-&gt;getAuthorMail().'&lt;/a&gt;&lt;/td&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      &lt;tr&gt;
                      &lt;td width="10%" valign="middle"&gt;Eintrag:&lt;/td&gt;
                      &lt;th colspan="3" valign="top" height="100px"&gt;'.$entry-&gt;getEntryText().'&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;';
          }
      }
  }
  </code></pre>
  
  <p>Here's a <code>var_dump</code> of e.g. object:</p>
  
  <pre><code>object(GuestBookEntry)#2 (5) { ["id":protected]=&gt; string(1) "2" ["entryDate":protected]=&gt; int(1344696811) ["authorName":protected]=&gt; NULL ["authorMail":protected]=&gt; NULL ["entryText":protected]=&gt; NULL }
  </code></pre>
  
  <p>update: well here is the rest of GuestBookEntry class:</p>
  
  <pre><code>public function __construct($authorName, $authorMail, $entryText) {
         $this-&gt;authorName    = $authorName;
         $this-&gt;authorMail    = $authorMail;
         $this-&gt;entryDate     = time();
         $this-&gt;entryText     = $entryText;
      }
  
      public function getId() {
         return $this-&gt;id;
      }
      public function getAuthorName() {
         return (String) $this-&gt;authorName;
      }
      public function getAuthorMail() {
         return (String) $this-&gt;authorMail;
      }
      public function getEntryDate() {
         return date('d.n.Y', $this-&gt;entryDate);
      }
      public function getEntryText() {
         return $this-&gt;entryText;
      }
  
      public function setAuthorName($authorName) {
         $this-&gt;authorName=$authorName;
      }   
      public function setAuthorMail($authorMail) {
         $this-&gt;authorMail=$authorMail;
      }
      public function setEntryDate($entryDate) {
         $this-&gt;entryDate=$entryDate;
      }
      public function setEntryText($entryText) {
         $this-&gt;entryText=$entryText;
      }
  </code></pre>