I have some data in array format which I wrote to a file in application/cache
folder.
Format is:
$extra_data['some_key'] = 'some_data';
It is not directly about site config so I don't want to put it in application/config
. Yet, in some cases, I need to reach this $extra_data
inside the controller or model.
What I do is,
1) define variable in controller
class pages_model extends CI_Model
{
var $extra_data;
2) inclulde the cache file and associate it with above variable,
function __construct()
{
parent::__construct();
@include_once APPPATH . "cache/extra_data.php";
$this->extra_data = $extra_data;
}
3) get the class variable as variable then use it:
function func_name()
{
$extra_data = $this->extra_data;
This is the way I am using, but I am not sure that it is the correct or efficient way.
Thanks for any idea and suggesstion.