2010-02-02 59 views
0

我打算创建一个处理联系页面的控制器。我创建了控制器ContactsController。问题是它要求一张同名的表格:CakePHP需要一个数据库表

Missing Database Table

Error: Database table username_contacts for model Contact was not found.

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

我真的需要创建一个没有数据的表吗?

这是我的控制器代码:

<?php 
class ContactsController extends AppController { 

    var $name = 'Contacts'; 


    function index($id = null) 
    { 
     $this->set('page', ClassRegistry::init('Page')->findByShortname($id)); 
    } 
} 

回答

3
var $name = 'Contacts'; 
var $uses = array(); 

不要成为那个人,但这是很好证明。 http://book.cakephp.org

+0

没有问题的亚当。我也认为这将被记录。 – 2010-02-03 01:11:58

2

无论如何,您可能想要创建模型,因为您几乎肯定会发现需要执行某些数据库类型的任务。它并不需要使用db_table:

class ModelWithoutTable extends AppModel 
{ 
    var $useTable = false; 
} 

认为“胖模型 - 瘦控制器”