2016-06-10 36 views
0

這是錯誤:它不會找到我的課,即使存在

致命錯誤:類「Admin_Controller」用C未找到:\ XAMPP \ htdocs中\ CI-博客主\程序\模塊\管理員\控制器\的settings.php第4行 甲PHP錯誤遇到

嚴重性:錯誤

消息:類 'Admin_Controller' 未找到

文件名:控制器/的settings.php

行號:4

回溯:

這裏是我的代碼爲:

Admin_controller.php

<?php defined('BASEPATH') OR exit('No direct script access allowed'); 

class Admin_Controller extends MY_Controller { 

function __construct() 
{ 
parent::__construct(); 
} 
} 

這裏是我的settings.php

class Settings extends Admin_Controller { 

    public function __construct(){ 
     parent::__construct(); 
     $this->allow_group_access(array('admin')); 

     $this->load->model('Category'); 
     $this->data['parent_menu'] = 'post'; 
    } 

    public function index(){ 
     $this->session->set_flashdata('message',message_box('Setting is the coming soon feature!','danger')); 
     redirect('admin/posts/index'); 

     $config['base_url'] = site_url('admin/categories/index/'); 
     $config['total_rows'] = count($this->Category->find()); 
     $config['per_page'] = 10; 
     $config["uri_segment"] = 4; 

     $this->data['categories'] = $this->Category->find($config['per_page'], $this->uri->segment(4)); 

     $this->data['pagination'] = $this->bootstrap_pagination($config); 
     $this->render('admin/categories/index'); 
    } 

    public function add(){ 
     $this->form_validation->set_rules('name', 'name', 'required|is_unique[categories.name]'); 
     $this->form_validation->set_rules('status', 'status', 'required'); 

     if($this->form_validation->run() == true){ 
      $category = array(
       'name' => $this->input->post('name'), 
       'status' => $this->input->post('status') 
      ); 
      $this->Category->create($category); 
      $this->session->set_flashdata('message',message_box('Category has been saved','success')); 
      redirect('admin/categories/index'); 
     } 

     $this->render('admin/categories/add'); 
    } 

    public function edit($id = null){ 
     if($id == null){ 
      $id = $this->input->post('id'); 
     } 

     $this->form_validation->set_rules('name', 'name', 'required'); 
     $this->form_validation->set_rules('status', 'status', 'required'); 

     if($this->form_validation->run() == true){ 
      $category = array(
       'name' => $this->input->post('name'), 
       'status' => $this->input->post('status') 
      ); 
      $this->Category->update($category, $id); 
      $this->session->set_flashdata('message',message_box('Category has been saved','success')); 
      redirect('admin/categories/index'); 
     } 

     $this->data['category'] = $this->Category->find_by_id($id); 

     $this->render('admin/categories/edit'); 
    } 

    public function delete($id = null){ 
     if(!empty($id)){ 
      $this->Category->delete($id); 
      $this->session->set_flashdata('message',message_box('Category has been deleted','success')); 
      redirect('admin/categories/index'); 
     }else{ 
      $this->session->set_flashdata('message',message_box('Invalid id','danger')); 
      redirect('admin/categories/index'); 
     } 
    } 

    public function update_multiple(){ 
     #test commit 
     #test commit di branch sendiri 
    } 
} 
+0

只是一個想法,但你嘗試過:class Admin_controller extends MY_Controller – Joe

回答

0

你可以在MY_Controller.php file:

<?php defined('BASEPATH') OR exit('No direct script access allowed'); 

class MY_Controller extends CI_Controller 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    public function some_mycontr_method() 
    { 
     // appropriate code here 
    } 
} 

class Admin_Controller extends MY_Controller 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    public function some_admin_method() 
    { 
     // appropriate code here 
    } 
} 
相關問題