示例#1
0
 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);
 }
示例#2
0
文件: mysql.php 项目: rosarion/core
 /**
  * @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);
 }
示例#3
0
 /**
  * @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);
 }