Welcome Guest, Not a member yet? Register   Sign In
[Solved] Very Confused Why Migrations Not Working.
#1

[eluser]riwakawd[/eluser]
I am just stumbled at the moment. I am trying to get my migrations to load as soon as codeigniter database.php has a database name.

But the reason I found out migrations not working is because it loads at the same time. As when the database information gets sent to the database.php

I have tried to make a test connection then run migrations but still same issue.

I would like to be able to run migrations when database.php has a database name. On the same controller. I have also loaded migrations into the form validation and same issue.

Not working out for me so far.

Code:
$this->load->library('form_validation');

    if ($this->form_validation->run($this) == false) {

    $this->load->view('template/step_3', $data);
  
  } else {

  $data = array();
  $data['hostname'] = $this->input->post('hostname');
  $data['username'] = $this->input->post('username');
  $data['password'] = $this->input->post('password');
  $data['database'] = $this->input->post('database');
  $data['driver'] = $this->input->post('driver');
  $data['prefix']  = $this->input->post('prefix');

  $data  = $this->load->view('template/configuration/database', $data, true);
  write_file(dirname(FCPATH) . '/admin/application/config/database.php', $data, 'r+');
  write_file(dirname(FCPATH) . '/catalog/config/database.php', $data, 'r+');
  write_file(FCPATH . '/application/config/database.php', $data, 'r+');

  $this->test_db_connection();
  redirect('step_4');
  }
}

function test_db_connection() {
    $hostname = $this->input->post('hostname');
    $database = $this->input->post('database');
    $username = $this->input->post('username');
    $password = $this->input->post('password');
    $driver   = $this->input->post('driver');

    if($driver == 'mysqli') {
     $this->load->library('migration');
  $this->migration->version(1);
       return function_exists('mysqli_connect') && @mysqli_connect($hostname, $username, $password, $database);
    }

    $link = @mysql_connect($hostname, $username, $password);
    return $link && mysql_select_db($database, $link);
}




Theme © iAndrew 2016 - Forum software by © MyBB