Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://book.cakephp.org/view/1479/Class-methods" rel="nofollow">CakePHP's <code>Inflector</code></a></p> <pre><code>function get_table_name() { $tbl_name = Inflector::pluralize($this-&gt;name); } </code></pre> <p>OR the <a href="http://api13.cakephp.org/class/inflector#method-Inflectortableize" rel="nofollow"><code>tableize</code></a> method</p> <pre><code>function get_table_name() { $tbl_name = Inflector::tableize($this-&gt;name); } </code></pre> <p><strong>Edit</strong></p> <p>This also addresses the apparent "ghost" issue with <code>$this-&gt;table</code> in the Model.</p> <p><a href="http://api13.cakephp.org/view_source/model/#line-403" rel="nofollow">Digging around in the <code>__construct</code> for <code>Model</code></a> I discovered two things:</p> <ol> <li><p>Cake uses <code>Inflector::tableize()</code> to get the table name. <strong>This alone</strong> is enough to warrant using <code>tableize</code> over <code>pluralize</code>. You'll get consistent results.</p></li> <li><p><code>$this-&gt;table</code> is not set by the <code>Model::__construct()</code> unless <code>$this-&gt;useTable === false</code> AND <code>$this-&gt;table === false</code>.</p></li> </ol> <p>It appears that if you know you haven't set <code>$this-&gt;useTable</code> to <code>false</code> you should be able to use this over <code>$this-&gt;table</code>. Admittedly though I only briefly scanned the source and I haven't really dug deep enough to say why <code>$this-&gt;table</code> isn't working sometimes.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload