public function dbAction() { $this->view->form = $form = new Install_Form_DbInfo(); // Make session if ($this->_getParam('clear')) { unset($this->_session->database); } if (!$this->getRequest()->isPost()) { if (!empty($this->_session->database) && is_array($this->_session->database)) { $vals = $this->_session->database['params']; unset($vals['password']); $form->populate($vals); } return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $params = $form->getValues(); $adapter = $params['adapter']; unset($params['adapter']); // Add some special magic if ($adapter == 'mysqli') { $params['driver_options'] = array('MYSQLI_OPT_CONNECT_TIMEOUT' => '2'); } else { if ($adapter == 'pdo_mysql') { $params['driver_options'] = array(Zend_Db::ATTR_TIMEOUT => '2'); } } // Validate mysql options try { // Connect! $adapterObject = Zend_Db::factory($adapter, $params); $adapterObject->getServerVersion(); } catch (Exception $e) { return $form->addError('Adapter Error: ' . $e->getMessage()); } $this->_session->database['adapter'] = $adapter; $this->_session->database['params'] = $params; return $this->_doSuccessRedirect(); }
public function dbInfoAction() { $this->view->form = $form = new Install_Form_DbInfo(); // Make session if ($this->_getParam('clear')) { $this->_session->mysql = array(); } // Check post if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $this->_session->mysql = $form->getValues(); } else { return; } } if (empty($this->_session->mysql)) { return; } // Validate mysql options try { $config = $this->dbFormToConfig($this->_session->mysql); // Add some special magic if ($config['adapter'] == 'mysqli') { $config['params']['driver_options'] = array('MYSQLI_OPT_CONNECT_TIMEOUT' => '2'); } else { if ($config['adapter'] == 'pdo_mysql') { $config['params']['driver_options'] = array(Zend_Db::ATTR_TIMEOUT => '2'); } } // Connect! $adapter = Zend_Db::factory($config['adapter'], $config['params']); $adapter->getServerVersion(); } catch (Exception $e) { $form->addError('Adapter Error: ' . $e->getMessage()); if (APPLICATION_ENV == 'development') { echo $e; } return; } // Next! return $this->_helper->redirector->gotoRoute(array('action' => 'db-sanity'), 'install', true); }