为什么CakePHP中的查询结果中没有出现新的表列?

时间:2009-06-16 09:12:57

标签: mysql cakephp

我在我的表中添加了一个新列已经具有的属性(id,form_id(外键),类型,标签,大小,序列号,instr)      instr是我添加的新列。

我的应用程序在CakePHP和MySQL中。

我已经使用以下代码插入表中的属性但是单独没有插入字段instr。

function saveFieldname($data)//from untitledfieldname
{   
    $this->data['Attribute']['form_id'] = $this->find(  'all', array(
                                                        'fields' => array('Form.id'),
                                                        'order' => 'Form.id DESC'
                                                     ));

    $this->data['Attribute']['form_id'] = $this->data['Attribute']['form_id'][0]['Form']['id'];

    $this->data['Attribute']['label'] = 'Label';
    $this->data['Attribute']['size'] ='50';
    $this->data['Attribute']['instr'] ='Fill';

    $this->data['Attribute']['type'] = $data['Attribute']['type'];
    $this->data['Attribute']['sequence_no'] = $data['Attribute']['sequence_no'];

    $this->Attribute->save($this->data);
}

请建议我..

2 个答案:

答案 0 :(得分:7)

有关表结构的信息可能已缓存。删除“app / tmp / cache / models”的内容并再次尝试。

答案 1 :(得分:1)

请注意,在开发过程中,app / config / core.php中的调试级别通常设置为>这意味着你永远不应该遇到开发中的问题,因为Cake不会缓存。但是,在生产中,core.php中的debug设置为0,从而导致cake开始缓存。

除此之外,我已经删除了app / tmp / cache / models中的缓存文件,就像在我的生产CakePHP应用程序中指定的dhofstet一样,查找查询仍然没有抓住我的新列。

-

除了清除模型缓存文件之外,我还在生产站点上将调试级别设置为2并进行页面刷新,然后将其设置为0并使其再次运行。我知道这是一种丑陋的方法,但是当没有其他方法可行时,它就为我解决了这个问题。

相关问题