简体   繁体   English

CakePHP的新功能->如何向MySQL表添加列?

[英]New to CakePHP -> How To Add Columns To a MySQL Table?

I had a website made for me a long time ago, and the programmer did it in CakePHP. 很久以前,我有一个网站专为我设计,程序员使用CakePHP进行了开发。 I'm now editing his scripts. 我现在正在编辑他的脚本。

I added a couple columns to a table, and found that doing saveField() on the new column does not do anything. 我在表中添加了几列,发现在新列上执行saveField()不会执行任何操作。 How do I make CakePHP recognize the new columns? 如何使CakePHP识别新列?

I'd appreciate your help. 多谢您的协助。 I'm not too familiar with CakePHP, so please go easy on me =) 我对CakePHP不太熟悉,所以请对我轻松点=)

The cache data is saved in YourAppFoloer/tmp/cache/models (delete the files there-in) 缓存数据保存在YourAppFoloer/tmp/cache/models (删除其中的文件)

You can also try Cache::clear() 您也可以尝试Cache::clear()

http://book.cakephp.org/view/1382/Clearing-the-Cache http://book.cakephp.org/view/1382/Clearing-the-Cache

Edit - this looked horrible in the comment: 编辑-这在评论中看起来很可怕:

You could add it to a controller to call: 您可以将其添加到控制器以调用:

function superHandyCacheClearer() { $this->autoRender = false; 函数superHandyCacheClearer(){$ this-> autoRender = false; Cache::clear(); 缓存::明确(); } }

And call www.yourcakeapp.com/yourControllerYouAddedItTo/superHandyCacheClearer - but really, this is when you're making changes whilst in the code. 并调用www.yourcakeapp.com/yourControllerYouAddedItTo/superHandyCacheClearer-但实际上,这是在代码中进行更改时。 Deleting the cache folder contents, really, should be the fix 删除缓存文件夹的内容,真的,应该修复

make sure that the cache folder is still laid out like it was initially 确保缓存文件夹的布局仍然像最初一样

cache
   models
   persistent
   views

And that they are all 'writable' by the webserver, also note that unless you are running with a debug level of 0 some cache files may not be created every request. 而且它们都是可被Web服务器“写入”的,还请注意,除非您以0的调试级别运行,否则可能不会在每个请求中都创建一些缓存文件。 But remember that anytime you alter the model files or the database itself you should clear the cache/models folder. 但是请记住,无论何时更改模型文件或数据库本身,都应清除cache / models文件夹。

HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM