Take the 2-minute tour ×

I have a CakePHP model which looks like this (and works fine):

class Paper extends AppModel {
      var $name = 'Paper';
      var $displayField = 'id';

This gives no error since I have a papers table in my database.

When I change the model to so (I simply add that last line):

class Paper extends AppModel {
      var $name = 'Paper';
      var $displayField = 'id';

      var $belongsTo = 'User';

I get the error:

Missing Database Table

Error: Database table ps for model Papers was not found.

Notice: If you want to customize this error message, create app\views\errors\missing_table.ctp

What could be going wrong that CakePHP suddenly assumes some first and last character nomenclature on adding a belongsTo line?


I may be wrong with this, but shouldn't the error say model Paper? It's saying Papers instead. This happens after adding the belongsTo statement. Is this where the error is?

share|improve this question
table "ps"? is your table not named "papers"? if not, you need to add var $useTable="ps"; –  alexdd55 Jun 28 '11 at 6:36
My table IS named 'papers'. But it still says 'ps not found' I want it to use 'papers'. In fact it does so until I add the belongsTo statement :/ –  Angad Jun 28 '11 at 6:37
How does the User model look like? If you have $hasMany = 'Papers' or something like that there you might get that error. –  Juhana Jun 28 '11 at 8:45
What happens if you comment out the var $displayField = 'id'; line? –  generalopinion Jun 28 '11 at 13:49
add comment

1 Answer

up vote 0 down vote accepted

I managed to fix this issue.

Simply put, model-model links are not a one-way street as the CakePHP documentation calls it.

For example if model A belongsTo model B, then model B MUST hasOne or hasMany model A.

In my case, syntax at the receiving end was faulty.

share|improve this answer
add comment

Your Answer


