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?
EDIT
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?
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
belongsTomodel B, then model B MUSThasOneorhasManymodel A.In my case, syntax at the receiving end was faulty.