CakePHP - 缺少数据库表

时间:2011-09-14 20:48:18

标签: apache cakephp

所以我的服务器在本地机器上运行。一切都在那里工作,我只想通过添加代理模型来扩展服务器的可能性。 然后我将所有文件放到开发服务器上,使其在线可用 - 当我尝试转到“代理商”(domain.com/agencies/)时 - 显示缺少数据库表错误。

我的电脑上的一切正常。 如果数据库中的所有名称都正确,我已经检查了5次。 我已经检查了cakephp中的database.cfg,但它一定很好 - 其他一切都在那里工作。

请帮忙!

更新

清除模型缓存没有帮助

以下是模型的代码:

<?php
class Agency extends AppModel{
var $name = 'Agency';

var $validate = array(
    'id' => array(
        'blank' => array(
            'rule' => array('blank'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => true,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'company' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'website_url' => array(
        'url' => array(
            'rule' => array('url'),
            //'message' => 'Your custom message here',
            'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'status' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'profession_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            'message' => 'Please select at least 1 profession',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'seniority_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'industry_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'sector_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'zone_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'size' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    )
);

var $hasAndBelongsToMany = array(
    'Profession' => array(
        'className' => 'Profession',
        'joinTable' => 'agencies_professions',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'profession_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    ),
    'Seniority' => array(
        'className' => 'Seniority',
        'joinTable' => 'agencies_seniorities',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'seniority_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    ),
    'Industry' => array(
        'className' => 'Industry',
        'joinTable' => 'agencies_industries',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'industry_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    ),
    'Sector' => array(
        'className' => 'Sector',
        'joinTable' => 'agencies_sectors',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'sector_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    ),
    'Zone' => array(
        'className' => 'Zone',
        'joinTable' => 'agencies_zones',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'zone_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    )
);

 var $hasMany= array(
    'Office' => array(
        'className' => 'Office',
        'foreignKey' => 'office_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )
 );
}

更新

调试从一开始就设置为2,因为它是一个开发服务器。

更新

这不是小写/大写名称的问题。

2 个答案:

答案 0 :(得分:1)

每当您对数据库进行任何更改时,请确保您的app / config / core.php文件调试值为2. Configure::write('debug', 2);

如果为0,则无法检测到数据库更改。

这是因为在生产中,Cake缓存数据库结构,这样就不必在每次加载页面时再次查询db。这很少是一个问题,因为您应该将调试级别设置为2进行开发。

因此,每当您更改数据库时,只需将其设为2次。

答案 1 :(得分:0)

问题解决了。我添加新表的数据库不是连接到开发服务器的数据库,而是连接到主站点。