protected function getToDBConnection(InputInterface $input, OutputInterface $output) { $type = $input->getArgument('type'); $connectionParams = array('host' => $input->getArgument('hostname'), 'user' => $input->getArgument('username'), 'password' => $input->getOption('password'), 'dbname' => $input->getArgument('database'), 'tablePrefix' => $this->config->getValue('dbtableprefix', 'oc_')); if ($input->getOption('port')) { $connectionParams['port'] = $input->getOption('port'); } return $this->connectionFactory->getConnection($type, $connectionParams); }
/** * @return \OC\DB\Connection * @throws \OC\DatabaseSetupException */ private function connect() { $type = 'mysql'; $connectionParams = array('host' => $this->dbHost, 'user' => $this->dbUser, 'password' => $this->dbPassword, 'tablePrefix' => $this->tablePrefix); $cf = new ConnectionFactory(); return $cf->getConnection($type, $connectionParams); }
/** * @return \OC\DB\Connection * @throws \OC\DatabaseSetupException */ private function connect() { $connectionParams = array('host' => $this->dbHost, 'user' => $this->dbUser, 'password' => $this->dbPassword, 'tablePrefix' => $this->tablePrefix); // adding port support if (strpos($this->dbHost, ':')) { // Host variable may carry a port or socket. list($host, $portOrSocket) = explode(':', $this->dbHost, 2); if (ctype_digit($portOrSocket)) { $connectionParams['port'] = $portOrSocket; } else { $connectionParams['unix_socket'] = $portOrSocket; } $connectionParams['host'] = $host; } $cf = new ConnectionFactory(); return $cf->getConnection('mysql', $connectionParams); }