Ejemplo n.º 1
0
 public function step_database()
 {
     $this->content = View::factory('step_database')->bind('form', $form);
     $this->title = 'Database Configuration';
     $form = array('username' => '', 'password' => '', 'hostname' => '', 'database' => '');
     if ($_POST) {
         $data = array('username' => $username = $this->input->post('username'), 'password' => $password = $this->input->post('password'), 'hostname' => $hostname = $this->input->post('hostname'), 'database' => $database = $this->input->post('database'), 'table_prefix' => '');
         try {
             installer::check_database($username, $password, $hostname, $database);
             Session::instance()->set('database_data', $data);
             url::redirect('install/step_create_data');
         } catch (Exception $e) {
             $form = arr::overwrite($form, $this->input->post());
             $error = $e->getMessage();
             // TODO create better error messages
             switch ($error) {
                 case 'access':
                     $this->error = 'wrong username or password';
                     break;
                 case 'unknown_host':
                     $this->error = 'could not find the host';
                     break;
                 case 'connect_to_host':
                     $this->error = 'could not connect to host';
                     break;
                 case 'select':
                     $this->error = 'could not select the database';
                     break;
                 default:
                     $this->error = $error;
             }
         }
     }
 }