Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 一个控制器用于codeigniter中的某些模型和视图_Php_Codeigniter - Fatal编程技术网

Php 一个控制器用于codeigniter中的某些模型和视图

Php 一个控制器用于codeigniter中的某些模型和视图,php,codeigniter,Php,Codeigniter,我有三个模型:添加客户模型、添加发布模型和添加项目模型。我还有三个视图:add_customer.tpl、add_post.tpl和add_project.tpl。我想为他们做一个控制器。这是: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class ADD extends MX_Controller { public $mname, $tag, $tpl; function

我有三个模型:添加客户模型、添加发布模型和添加项目模型。我还有三个视图:add_customer.tpl、add_post.tpl和add_project.tpl。我想为他们做一个控制器。这是:

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

class ADD extends MX_Controller {

public $mname, $tag, $tpl;

function __construct()
{
    $this->mname=strtolower(get_class());// imya modulya               
    $this->tag=strtoupper($this->mname); // TAG v shablone   
} 


//add_customer
public function index()
{   
    include APPPATH."language/".LANG.".php";

    $userGROUP = $this->session->userdata('_userGROUP');
    if($userGROUP!=='Administrator')
    {
        show_404('page');
        exit; 
    }
    $this->load->model($this->mname.'/add_customer_model');
   // $model=$this->mname.'_model';
    //$this->$model->index($this->mname);
    $a['IsEnabled']=$LANGUAGE['IsEnabled']; 
    $a['Submit']=$LANGUAGE['Submit'];
    $a['Cancel']=$LANGUAGE['Cancel'];
    $a['Reset']=$LANGUAGE['Reset'];
    $a['Name']=$LANGUAGE['Name'];
    $a['Project Name']=$LANGUAGE['CustomerName'];
    $a['Customer Name']=$LANGUAGE['Customer Name'];

    $this->tp->assign($a);
    $this->tp->parse('CONTENT', $this->mname.'/add_customer.tpl');
}


//add_post
public function add_post()
{ 
    include APPPATH."language/".LANG.".php";

    $userGROUP = $this->session->userdata('_userGROUP');
    if($userGROUP=='Engineer')
    {
        show_404('page');
        exit; 
    }
    $this->load->model($this->mname.'/add_post_model');
   // $model=$this->mname.'_model';
    $this->$model->add_post($this->mname);
    $a['IsEnabled']=$LANGUAGE['IsEnabled']; 
    $a['Submit']=$LANGUAGE['Submit'];
    $a['Cancel']=$LANGUAGE['Cancel'];
    $a['Reset']=$LANGUAGE['Reset'];
    $a['Activity Name']=$LANGUAGE['Activity Name'];

    $this->tp->assign($a);
    $this->tp->parse('CONTENT', $this->mname.'/add_post.tpl');
}

//add_project   
public function add_project()
{ 
include APPPATH."language/".LANG.".php";

    $this->load->model($this->mname.'/add_project_model');
   // $model=$this->mname.'_model';
   // $this->$model->add_project($this->mname);
    $a['IsEnabled']=$LANGUAGE['IsEnabled']; 
    $a['Submit']=$LANGUAGE['Submit'];
    $a['Cancel']=$LANGUAGE['Cancel'];
    $a['Reset']=$LANGUAGE['Reset'];
    $a['Name']=$LANGUAGE['Name'];
    $a['SelectCustomer']=$LANGUAGE['SelectCustomer'];
    $a['Project Name']=$LANGUAGE['ProjectName'];
    $a['Manager']=$LANGUAGE['Manager'];
    $a['Customer']=$LANGUAGE['Customer'];
    $userGROUP = $this->session->userdata('_userGROUP');
    if ($userGROUP=='Administrator')
    $a['AddManager']='<button type="button" class="btn btn-warning" onclick="AddNewManager()">+</button>';
    else
    $a['AddManager']='';
    $this->tp->assign($a);
    $this->tp->parse('CONTENT', $this->mname.'/add_project.tpl');
}
这意味着:

$this->load->model('add/addadd_post_model');
不寻常的设置。我想如果您将其更改为以下内容,它可能会起作用:

$this->load->model($this->mname.'/add_post_model');
$this->load->model('add/addadd_post_model');
$this->load->model($this->mname.'/add_post_model');