public function databaseAction()
{
$this->checkInstall(4);
$this->installForm->database();
$messages = array();
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost()->toArray();
$this->installForm->setData($data);
if ($this->installForm->isValid()) {
//Test database connexion
$values = $this->installForm->getInputFilter()->getValues();
$config = array('driver' => $values['driver'], 'username' => $values['username'], 'database' => $values['dbname'], 'hostname' => $values['hostname'], 'password' => empty($values['password']) ? '' : $values['password']);
try {
$dbAdapter = new DbAdapter($config);
$dbAdapter->getDriver()->getConnection()->connect();
$session = $this->getSession();
$install = $session['install'];
$install['db'] = $config;
$session['install'] = $install;
return $this->redirect()->toRoute('install/configuration');
} catch (Exception $e) {
$messages[] = 'Can\'t connect to database';
$messages[] = $e->getMessage();
}
}
}
$this->layout()->setVariables(array('currentRoute' => $this->getRouteMatch()->getMatchedRouteName()));
return array('form' => $this->installForm, 'messages' => $messages);
}