Store constant variable without using database
I have a situation. I want to calculate the point depended on 2 pre-defined variables, let's say they are $limit and $point
For example: $limit = 100 => $point = 2
if I have k $limit, and the formula to calculate the $averagepoint is (k$limit * $point) / $limit
The question is. I want to set $limit and $point dynamically. It means I want to allow the user to set the amount of $limit and $point.
However, I do not want to store 开发者_StackOverflow社区the values which are given by the user for $limit and $point in database.
Where and How I suppose to store and do?
Any suggestion is valuable.
Thank you very much.
i may be missing something but when a user sets the data points why not set a cookie?
I don't know why you don't want to store it in the DB. But based on your requirement, the easiest way is using Configure class:
// save data Configure::store('<type>','<filename>', $data); // read data back Configure::load('<filename>'); $data= Configure::read('<type>');
type can be anything really, but the recommended options are 'Models', 'Controllers', 'Helpers', 'Components'
Interesting enough, the store function is not documented in the Cookbook (you can find it in the API)
精彩评论