2017-07-06 51 views
0

我有三个模型:add_customer_model,add_post_model和add_project_model。另外我有三个视图:add_customer.tpl,add_post.tpl和add_project.tpl。我想为他们制作一个控制器。那就是:一个控制器的一些模型和意见codeigniter

<?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'); 
} 

}

But in my browser I can see only add_customer page. But when I want to see add_post and add_project pages, it also shows me add_customer page. Where is a mistake? 

回答

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

这相当于:

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

不寻常的设置。我想如果你改变它到下面,它可能会工作:

$this->load->model($this->mname.'/add_post_model'); 
相关问题