How to build in 'maintenance mode' in Codeigniter?

前端 未结 6 1474
醉酒成梦
醉酒成梦 2020-12-15 00:20

I\'m using latest codeigniter and I need to create a flag (ideally in the config) when turned to \'true\', all pages display a \'maintenance mode\' message instead of execut

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 00:43

    how about this :

    1. create auto-loaded libraries which always check maintenance flag on your database.
    2. create a module for controlling your application maintenance flag.
    3. create a module for redirecting when maintenance mode is on

    auto-loaded libraries can contain something like this :

    class Maintenance_mode {
        function __construct(){
            $CI =& get_instance();
            $check_maintenance = $CI->db->select('flag_mode')->get('tbl_settings')->result();
            if($check_maintenance[0]->flag_mode == '1') 
                redirect(site_url('maintenance_mode_controller'));
        }
    }
    

    next step is to create a controller for maintenance page.

提交回复
热议问题