tags:

views:

88

answers:

2

I had a website made for me a long time ago, and the programmer did it in 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. How do I make CakePHP recognize the new columns?

I'd appreciate your help. I'm not too familiar with CakePHP, so please go easy on me =)

A: 

The cache data is saved in YourAppFoloer/tmp/cache/models (delete the files there-in)

You can also try Cache::clear()

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; Cache::clear(); }

And call www.yourcakeapp.com/yourControllerYouAddedItTo/superHandyCacheClearer - but really, this is when you're making changes whilst in the code. Deleting the cache folder contents, really, should be the fix

Dan Heberden
I appreciate your answer. Can you please clarify what to do with "Cache::clear()"? Is this something to include in a PHP script, or what? How do I run this command?I tried deleting the cache file I need, but it doesn't recreate the cache file.
walden
Deleting the files I needed worked--the columns I need can now be updated. However, why is the cache file not being recreated again? Does it take a certain amount of time or something?Thanks a lot.
walden
(see answer) - have you verified your saveField call is proper? tried it with a column that _was_ there? Maybe try a full insert? $model->field1 = 'content'; $model->save(); ?
Dan Heberden
I deleted everything in the tmp/cache/models folder, and the site has plenty of proper mysql queries, but none of the files there are appearing. The site still appears to be properly loading, though. I'm just concerned that I need those models cache files.
walden
I'm not 100% sure about their cache class, but i _do_ know when you installed cake, those files were NOT there and cake creates them. You probably haven't done enough db access to warrant cacheing as far as cake in concerned.
Dan Heberden
Ah, so probably it takes a lot more accesses? That could be it.Anyhow, is it a big problem if those files aren't there? My site gets a few thousand requests every day, so maybe without the cache files there will be more server load?
walden
Make sure "Configure::write('Cache.disable', true);" isn't uncommented in your core.php file and are you running debug 0?
Dan Heberden
Hmm... don't have that line at all. I have an old version; could that be the problem? Version is showing 1.1.19.6305. I found the following line related to cache though: define('CACHE_CHECK', false);Perhaps that's it?
walden
if that line is uncommented, it's disabling cache for your whole app - but then your original problem would have never happened.
Dan Heberden
It is uncommented... and yet I was having the problem, which is very strange. But at least I now know that I don't need those files =)Thanks a lot for your help. If only I could upvote your answer, I would, so I do apologize about that (I'm new to this site).
walden
Glad you got it resolved :) you can mark it as answered, i believe..
Dan Heberden
Doesn't look like I have that option anywhere =\
walden
http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work
Dan Heberden
+1  A: 

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. But remember that anytime you alter the model files or the database itself you should clear the cache/models folder.

HTH

Sam D