2017-04-26 1 views
0

각 테넌트에 대한 설정의 일부로 새 데이터베이스를 만들고 db가 성공적으로 생성되었지만 약 5 분이 소요됩니다. 다른 컨트롤러 메소드, 즉 admin_list 컨트롤러와 manage_package 메소드를 호출 할 수 없습니다.codeigniter에서 다른 컨트롤러 메서드를 호출 할 수 없습니다

<?php 
 
class login extends CI_Controller 
 
{ 
 
    var $data; 
 

 
    function __construct() { 
 
     parent::__construct(); 
 
\t \t $this->load->helper('cookie'); 
 
\t \t require_once(APPPATH.'controllers/admin_list.php'); 
 

 
\t \t $is_admin_logged_in = $this->admin_init_elements->admin_logged_in_status(); 
 
\t \t global $USER; 
 
\t \t if($is_admin_logged_in == TRUE){ 
 
\t \t \t redirect('home'); 
 
\t \t \t //; 
 
     } 
 

 
     //populate viewfor header/footer elements 
 
     
 
     $this->admin_init_elements->init_elements('N'); 
 
\t \t $this->load->model('mod_login'); 
 
\t \t 
 
    } 
 

 
public function save_userinput() 
 
    { 
 
     //code goes here 
 
     // for example: getting the post values of the form: 
 
     $form_data = $this->input->post(); 
 
     // or just the username: 
 
     $username = $this->input->post("username"); 
 
\t echo $username; 
 
\t // $this->admin_list->manage_package(); 
 
     $this->load->dbforge(); 
 

 
\t 
 
    if ($this->dbforge->create_database($username)) 
 
{ 
 
    try{ 
 
     $current_database = $username; 
 
     $this->db->database = $current_database; 
 
\t 
 
    $this->db->close(); 
 
    $config['hostname'] = "localhost"; 
 
    $config['username'] = "root"; 
 
    $config['password'] = ""; 
 
    $config['database'] = $current_database; 
 
    $config['dbdriver'] = "mysql"; 
 
    $config['dbprefix'] = $username; 
 
    $config['pconnect'] = FALSE; 
 
    $config['db_debug'] = TRUE; 
 
    $config['cache_on'] = FALSE; 
 
    $config['cachedir'] = ""; 
 
    $config['char_set'] = "utf8"; 
 
    $config['dbcollat'] = "utf8_general_ci"; 
 
    $this->load->database($config); 
 
    $fields = array(
 
         'id' => array(
 
               'type' => 'INT', 
 
               'constraint' => 11, 
 
               'unsigned' => TRUE, 
 
               'auto_increment' => TRUE 
 
             ), 
 
\t \t \t \t \t \t 'home_bg' => array(
 
               \t 'type' => 'VARCHAR', 
 
               'constraint' => '200', 
 
             ), 
 
         'login_bg' => array(
 
               'type' => 'VARCHAR', 
 
               'constraint' => '200', 
 
             ), 
 
         'other_bg' => array(
 
               'type' =>'VARCHAR', 
 
               'constraint' => '200', 
 
                
 
             ), 
 
         'uploaded_on' => array(
 
               'type' => 'DATE', 
 
                
 
             ), 
 
       ); 
 

 
    $this->dbforge->add_field($fields); 
 
    $this->dbforge->add_key('id', TRUE); 
 
    $this->dbforge->create_table('pr_backgrounds', TRUE); 
 

 

 

 
$fields = array(
 
         'id' => array(
 
               'type' => 'BIGINT', 
 
               'constraint' => 15, 
 
               'unsigned' => TRUE, 
 
               'auto_increment' => TRUE 
 
             ), 
 
\t \t \t \t \t \t 'username' => array(
 
              'type' => 'VARCHAR', 
 
               'constraint' => '255', 
 
\t \t \t \t \t \t \t \t \t \t \t \t 'default' => '[email protected]', 
 
             ), 
 
         'userpass' => array(
 
               'type' => 'VARCHAR', 
 
               'constraint' => '255', 
 
\t \t \t \t \t \t \t \t \t \t \t \t 'default' => '65e1b655a6d6f4cbed20554d3b52521a743afdc0', 
 
             ), 
 
         'email' => array(
 
               'type' =>'VARCHAR', 
 
               'constraint' => '255', 
 
               'default' => '[email protected]', 
 
             ), 
 
         'departmentid' => array(
 
                'type' => 'BIGINT', 
 
               'constraint' => 15, 
 
               'default' => '1', 
 
                
 
             ), 
 
\t \t \t \t \t \t 'userroleid' => array(
 
                'type' => 'BIGINT', 
 
               'constraint' => 15, 
 
               'default' => '4', 
 
                
 
             ), 
 
\t \t \t \t \t  'managerid' => array(
 
               'type' =>'VARCHAR', 
 
               'constraint' => '255', 
 
                'default' => '10', 
 
             ), 
 
\t \t \t \t \t \t 'userlevel' => array(
 
                'type' => 'INT', 
 
               'constraint' => 11, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t \t 'branchid' => array(
 
                'type' => 'INT', 
 
               'constraint' => 11, 
 
               'default' => '2', 
 
             ), 
 
\t \t \t \t \t \t 'is_global' => array(
 
                'type' => 'TINYINT', 
 
               'constraint' => 4, 
 
               
 
               'default' => '0', 
 
             ), 
 
\t \t \t \t \t \t 'registrationtime' => array(
 
                'type' => 'INT', 
 
               'constraint' => 10, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t \t 'timemodified' => array(
 
               'type' => 'BIGINT', 
 
               'constraint' => 10, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t  'modifierid' => array(
 
                'type' => 'BIGINT', 
 
                'constraint' => 15, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t \t \t \t \t \t \t  'status' => array(
 
                'type' => 'TINYINT', 
 
                'constraint' => 1, 
 
               
 
                
 
             ), 
 

 
\t \t   'deleted' => array(
 
                'type' => 'TINYINT', 
 
                'constraint' => 1, 
 
               
 
                
 
             ), 
 
\t \t \t \t  'temppass' => array(
 
                'type' => 'VARCHAR', 
 
                'constraint' => 20, 
 
               
 
                
 
             ), 
 

 
\t \t \t \t \t  'temppassvalidtill' => array(
 
                'type' => 'BIGINT', 
 
               'constraint' => 15, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t \t  'lastlogin' => array(
 
                'type' => 'BIGINT', 
 
               'constraint' => 10, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t \t 'lastrefresh' => array(
 
                'type' => 'BIGINT', 
 
               'constraint' => 15, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t \t \t \t 'lastloginip' => array(
 
                'type' => 'VARCHAR', 
 
               'constraint' => 20, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t \t \t \t 'if_online' => array(
 
                'type' => 'INT', 
 
               'constraint' => 11, 
 
               
 
                
 
             ), 
 
\t \t \t \t \t \t \t \t 'pfield' => array(
 
                'type' => 'VARCHAR', 
 
               'constraint' => 255, 
 
               
 
                
 
             ), 
 
       ); 
 

 
    $this->dbforge->add_field($fields); 
 
    $this->dbforge->add_key('id', TRUE); 
 
    $this->dbforge->create_table('pr_users', TRUE); 
 

 

 
$sql = file_get_contents("assets/bizzlatestdb.sql"); 
 

 
/* 
 
Assuming you have an SQL file (or string) you want to run as part of the migration, which has a number of statements... 
 
CI migration only allows you to run one statement at a time. If the SQL is generated, it's annoying to split it up and create separate statements. 
 
This small script splits the statements allowing you to run them all in one go. 
 
*/ 
 

 
$sqls = explode(';', $sql); 
 
array_pop($sqls); 
 

 
foreach($sqls as $statement){ 
 
    $statment = $statement . ";"; 
 
    $this->db->query($statement); 
 
\t 
 
} 
 

 

 

 
    } 
 
\t 
 
\t catch(Exception $e){ 
 
     echo "This name already exists in our database , Please choose another company name"; 
 
\t die; 
 
    } 
 
    $this->admin_list->manage_package(); 
 

 
    } 
 

 

 
     // then do whatever you want with it :) 
 

 
    } 
 
    function index(){ 
 
    
 
\t \t 
 
\t \t $this->load->view('login', $this->data); 
 

 
     
 
    } 
 

 
\t  
 
} 
 
    
 
?>

+0

]을 참조 [이 (http://stackoverflow.com/questions/14165895/how-to-load-a-controller-from-another-controller- in-codeigniter) Answer –

+0

실제 질문은 무엇입니까? 또한 http://stackoverflow.com/help/how-to-ask –

+0

을 읽어야합니다.이 링크를 시도해야합니다. http://stackoverflow.com/questions/9494492/codeigniter-extending-multiple-controllers –

답변

3

당신은 Codeigniter2에서 라이브러리로 컨트롤러를로드 할 수 있습니다 : 이것은 내 컨트롤러 코드입니다. 하지만 Codeigniter3에서 가능하지 않다고 생각합니다. 라이브러리로

부하 컨트롤러 :

$this->load->library('../controllers/controller_name'); 

# Calling Methdod 

$this->controller_name->method_name(); 
+0

는 공란을 제공합니다. $ this-> load-> library ('../ controllers/admin_list')를 추가하는 화면; – sunshine

+0

사용중인 Codeigniter의 버전은 2 또는 3입니까? –

+0

codeigniter 버전 2 – sunshine

관련 문제