0
votes

I am developing an app using the CakePHP framework. I just recently read an article that said enabling

var $persistModel = true;

could lead to performance gains. As I am working on a development server I thought I'd give it a try. Lo and behold the site was slightly faster at the cost of losing form automagic. For example, all users have group_ids, but instead of the form input being displayed as a drop-down, it was a simple textfield. However, when I disabled $persistModel form automagic worked as normal once again.

I have made sure to set a variable called $groups in the view, and the User model has a proper $belongsTo association.

Does anybody have any insight as to why this might be happening? Is there a way I can use $persistModel and form automagic at the same time? I'm obviously missing something here.

Thanks a lot!

-wes

1
Is there a reason you're concerned about the performance increase (or does persistModel have other advantages as well)? How much faster was it? - Travis Leleu
It wasn't too much faster. I'm not overly concerned with performance. I've optimized my queries and database indices to eliminate the big stress. I'd just like the thing to be faster. As this post might hint, I'm not willing to sacrifice features that make Cake great just for a few milliseconds. But if I could reclaim those millis I might as well. - just_wes

1 Answers

2
votes

For those Googling this (like myself), the setting has been removed in CakePHP 2.0.

$persistModels does not exist anymore, the table structure is cached either in files or in APC cache if available (the faster APC cache is used if detected)

From http://groups.google.com/group/cake-php/browse_thread/thread/f241ff38a2368032