title: Computing table name from model name
body: <p>In my CakePHP application, I have a model like this:</p>
  
  <pre><code>class Duck extends AppModel {
      var $name = 'Duck';
  
      function get_table_name() {
          $tbl_name = //compute default table name for this model         
      }
  }
  </code></pre>
  
  <p>I would like to write the function <code>get_table_name()</code> that outputs the default table name for the model. For the example above, it should output <code>ducks</code>.</p>
  
  <p><strong>EDIT:</strong>
  Several people have pointed out the use of <code>$this-&gt;table</code>.
  I did small testing and found out the following:</p>
  
  <ol>
  <li>In the question as I have put above, <code>$this-&gt;table</code> indeed contains the table name.</li>
  <li><p>However, actually, my code looked more like this:</p>
  
  <pre><code>class Duck extends Bird {
      var $name = 'Duck';
      function get_table_name(){
          $tbl_name = //comput default table name for this model
      }
  }
  class Bird extends AppModel {
  
  }
  </code></pre>
  
  <p>In this case $this->table is empty string.
  I went with this approach because I wanted to share some code between two of my models. Looks like this is not a good way to share code between models which need some common functionality.</p></li>
  </ol>