I am trying to understand some fundamental aspects of CakePHP, I successfully completed the blog tutorial (I am doing the 1.3 version because the project I need to work on is a legacy CakePHP1.3 app), and just to test my skills I setup a new, bare bones model, view and controller under the same project with the structure and code below.
What I don’t understand is when I run this via localhost/foo/info/, while the address loads, the page reports it is looking for a database table called ‘foos’. If I add the table called ‘foos’, the page loads fine. But what I don’t understand is what would I have to do so I can run this same code independently of the database? In other words, so it runs without any database table called foos. I don’t understand where in the code below there is a request for a ‘foos’ table.
/app/models/foo.php
<?php
class Foo extends AppModel
{
}
?>
/app/views/foo/info.ctp
<!-- File: /app/views/foo/info.ctp -->
<h1>Info page</h1>
<p>This is an info page</p>
/app/controllers/foo_controller.php
<?php
class FooController extends AppController {
var $name = 'Foo';
function info() {
}
}
?>
In model:
public $useTable = false;OR
In controller:
public $uses = array();Further reading:
http://book.cakephp.org/2.0/en/models/model-attributes.html
http://book.cakephp.org/2.0/en/controllers.html#Controller::$uses