Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You don't have to follow the naming conventions for the database with Cake. It makes things a lot easier and keeps things very organized and structured. However, any framework that forces you to follow ITS patterns should through red flags. At least it does for me.</p> <p>That being said, the conventions are simple. Here are a few of the basics:</p> <ul> <li>Table names are pluralized (ie. users, computers, songs, teachers, children, etc.)</li> <li>Primary keys should be labeled as id</li> <li>The name field will be read automatically for display</li> <li>Foreign keys contain the singular name of the table _id (ie. user_id, computer_id, song_id, etc.)</li> </ul> <p><a href="http://book.cakephp.org/view/68/Creating-Database-Tables" rel="nofollow">http://book.cakephp.org/view/68/Creating-Database-Tables</a></p> <p>These are just the basics. Now they may not apply to every application. Especially if you already have existing tables you want to use. It doesn't make sense to convert the structure of the database to have to fit in with Cake. So there are variables you can use in the model to tell cake the name of the tables and fields you are using.</p> <p>To change the table name a model points to: <code>var $useTable = 'myTable';</code></p> <p>To tell cake what the display field is: <code>var $displayField = 'somefield';</code></p> <p>To tell cake what field to use as the PK: <code>var $primaryKey = 'some_id';</code></p> <p><a href="http://book.cakephp.org/view/71/Model-Attributes" rel="nofollow">http://book.cakephp.org/view/71/Model-Attributes</a></p> <p>This should be enough to get you going. Good luck!</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