N98\Util\Console\Helper\DatabaseHelper::getConnection PHP Method

getConnection() public method

Connects to the database without initializing magento
public getConnection ( Symfony\Component\Console\Output\OutputInterface $output = null ) : PDO
$output Symfony\Component\Console\Output\OutputInterface = null
return PDO
    public function getConnection(OutputInterface $output = null)
    {
        if (!$this->_connection) {
            $this->_connection = $this->getDbSettings($output)->getConnection();
        }
        return $this->_connection;
    }

Usage Example

 /**
  * @param string $sql
  *
  * @return array|bool
  */
 protected function _query($sql)
 {
     /** @var \PDO $connection */
     $connection = $this->dbHelper->getConnection($this->output);
     $query = $connection->prepare($sql);
     $query->execute();
     $result = $query->fetch(\PDO::FETCH_ASSOC);
     return $result;
 }