public function getConnection() { if (!$this->_conn) { if (!self::$_pdo) { self::$_pdo = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_DATABASE, DB_USERNAME, DB_PASSWORD); } $this->_conn = $this->createDefaultDBConnection(self::$_pdo, DB_DATABASE); } return $this->_conn; }
public function getConnection() { if (!$this->_conn) { $this->assertNotNull($this->_db_credentials, 'Database credentials specified'); if (!self::$_pdo) { self::$_pdo = new PDO('mysql:host=' . $this->_db_credentials['host'] . ';dbname=' . $this->_db_credentials['database'], $this->_db_credentials['username'], $this->_db_credentials['password']); } $this->_conn = $this->createDefaultDBConnection(self::$_pdo, $this->_db_credentials['database']); } return $this->_conn; }