model
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Countries_model extends CI_Model {
public function get_countries()
{
$query = $this->db->get('countries');
if ($query->num_rows() > 0) {
return $query->result();
} else {
return FALSE;
}
}
public function get_cache()
{
if ( ! $countries = $this->cache->get('countries')) {
$countries = $this->get_countries();
$this->cache->save('countries', $countries, 86400);
}
return $countries;
}
}
controller
$this->countries_model->get_cache();
No comments:
Post a Comment