0

I am creating a new database as part of the setup for each of my tenants, db is created successfully but is taking a lot of time , approx 5 min, on the other hand i am not able to call another controller method i.e admin_list controller and manage_package method inside it. This is my controller code:

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

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

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

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

 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");
   echo $username;
  // $this->admin_list->manage_package();
      $this->load->dbforge();

 
  if ($this->dbforge->create_database($username))
{
    try{
      $current_database = $username;
      $this->db->database = $current_database;
 
     $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
                                          ),
      'home_bg' => array(
                                               '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
                                          ),
      'username' => array(
                                             'type' => 'VARCHAR',
                                                 'constraint' => '255',
             'default' => 'admin@fold.com',
                                          ),
                        'userpass' => array(
                                                 'type' => 'VARCHAR',
                                                 'constraint' => '255',
             'default' => '65e1b655a6d6f4cbed20554d3b52521a743afdc0', 
                                          ),
                        'email' => array(
                                                 'type' =>'VARCHAR',
                                                 'constraint' => '255',
                                                 'default' => 'admin@fold.com', 
                                          ),
                        'departmentid' => array(
                                                  'type' => 'BIGINT',
                                                 'constraint' => 15,
                                               'default' => '1', 
                                                 
                                          ),
      'userroleid' => array(
                                                  'type' => 'BIGINT',
                                                 'constraint' => 15,
                                               'default' => '4', 
                                                 
                                          ),
         'managerid' => array(
                                                 'type' =>'VARCHAR',
                                                 'constraint' => '255',
                                                  'default' => '10', 
                                          ),
      'userlevel' => array(
                                                  'type' => 'INT',
                                                 'constraint' => 11,
                                               
                                                 
                                          ),
      'branchid' => array(
                                                  'type' => 'INT',
                                                 'constraint' => 11,
                                               'default' => '2',
                                          ),
      'is_global' => array(
                                                  'type' => 'TINYINT',
                                                 'constraint' => 4,
                                               
                                                 'default' => '0',
                                          ),
      'registrationtime' => array(
                                                  'type' => 'INT',
                                                 'constraint' => 10,
                                               
                                                 
                                          ),
      'timemodified' => array(
                                                'type' => 'BIGINT',
                                                'constraint' => 10,
                                               
                                                 
                                          ),
         'modifierid' => array(
                                                  'type' => 'BIGINT',
                                                  'constraint' => 15,
                                               
                                                 
                                          ),
                   'status' => array(
                                                  'type' => 'TINYINT',
                                                  'constraint' => 1,
                                               
                                                 
                                          ),

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

          'temppassvalidtill' => array(
                                                  'type' => 'BIGINT',
                                                 'constraint' => 15,
                                               
                                                 
                                          ),
          'lastlogin' => array(
                                                  'type' => 'BIGINT',
                                                 'constraint' => 10,
                                               
                                                 
                                          ),
         'lastrefresh' => array(
                                                  'type' => 'BIGINT',
                                                 'constraint' => 15,
                                               
                                                 
                                          ),
           'lastloginip' => array(
                                                  'type' => 'VARCHAR',
                                                 'constraint' => 20,
                                               
                                                 
                                          ),
           'if_online' => array(
                                                  'type' => 'INT',
                                                 'constraint' => 11,
                                               
                                                 
                                          ),
           '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);  
  
}



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

  }


      // then do whatever you want with it :)

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

       
    }

    
}
  
?>
tereško
  • 58,060
  • 25
  • 98
  • 150
sunshine
  • 371
  • 1
  • 4
  • 18

1 Answers1

3

You can load controller as library in Codeigniter2. But I don't think it is possible in Codeigniter3.

Load Controller as Library :

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

# Calling Methdod

$this->controller_name->method_name();
Touheed Khan
  • 2,149
  • 16
  • 26