Sometimes you don’t need to create a database table for each of the views you are coding because the VIEW will only call and use other MODEL(S) and perform CRUD operations in those MODEL(S) and not itself, for example a DETAIL page for an apartment might be calling and using models like OWNER, PROPERTY, FEATURES, and so on. Coding with CakePHP I found that while you might nod need a view with a table connection, letting the application know is required.
I am learning to use CakePHP, an MVC framework for fast development of web applications, and I coded just the CONTROLLER and the VIEW, thinking that it was all I needed to do. Wrong! I guess in an MVC framework I do need the M and not only the V and C (it makes sense).
This is the error I got when I didn’t have the MODEL deployed to the application folder yet:
“Error: Database table *** for model *** was not found.”
To fix the issue here are the steps I took:
- Created the Model (following specifications, is the singular name of the table, so for example, for a table named “records”, the model should be called “Record.php”).
- Wrote the following code:
- Upload the file to your folder application and the error should be fix. The Model is no longer looking for a table.
<?php
class Record extends AppModel {
var $useTable = false;
}
?>