Your issue is that $this->load does not exist in your class
One answer is to use 'post_controller_constructor'
. This allows you to extend the CI_Controller and get access to all the goodies.
$hook['post_controller_constructor'] = array(
'class' => 'Maintenance',
'function' => 'maintenance_check',
'filename' => 'Maintenance.php',
'filepath' => 'hooks'
);
Your Maintenance Class would look something like (I've got some debug code in there to see what was going on.)
<?php
class Maintenance extends CI_Controller {
public function maintenance_check() {
$this->load->database();
$result = $this->db->query('SELECT * FROM maintenance');
$mode = $result->row_array();
var_dump($mode['mode']);
if ($mode['mode'] == TRUE) {
echo 'maintenance';
}
}
}
Not quite sure as to your Schema for your maintenance table.
Sounds like it would be more suited to be an entry in an options table with
id, name, value.
So maybe something like
public function maintenance_check() {
$this->load->database();
$result = $this->db->query("SELECT value FROM options WHERE name='maintenance'");
$row = $result->row_array();
if ($row['value'] == TRUE) {
echo 'maintenance';
}
}