This method returns an instance of the database class

@return object The instance of this database class.
@throws This method does not throw an error
548684
public static function getDatabase()
	{
		//get the database settings from global space
        global $database;

        //create instance of database class
        $instance = new BaseDb($database['default'], $database[$database['default']]);

        //get connection instance and make attempt to connect to the database
        $instance = $instance->initialize()->connect();

		return $instance; 

	}
419618
public function getDb()
    {
        if (!$this->db) {
            $this->db = Bootstrap::getSingleton()->getDatabase();
        }
        return $this->db;
    }
81573
protected function getWordpressDatabaseInstance()
    {
        global $wpdb;

        if ((! \class_exists('wpdb')) || (! $wpdb) || (! $wpdb instanceof \wpdb)) {
            throw InvalidDatabaseInstanceException::wordpressDatabaseIsNotSet();
        }

        $this->db = $wpdb;
    }
651897
public function getDatabase()
    {
        if ($this->_oDatabaseObject === null) {
            $this->_oDatabaseObject = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
        }

        return $this->_oDatabaseObject;
    }
440960
public function cache()
    {
        if ($this->cache !== null) {
            return $this->cache;
        }
        switch ($this->driver) {
            case self::DRIVER_MYSQL:
                return $this->cache = new Cache\MySQL\Manage($this->pdo);
        }
        throw new DatabaseException('Unsupported PDO driver.');
    }
238892
public function getInstance()
    {
        if (!$this->instance && $this->getType() && $this->getLocation()) {
            switch ($this->getType()) {
                case static::TYPE_SQLITE:
                    $instance = $this->createPDOSQLite(
                        $this->getLocation(),
                        $this->getErrorMode()
                    );
                    $this->setInstance($instance);
                    break;
                case static::TYPE_MYSQL:
                    if (!$this->getUsername() || !$this->getPassword() || !$this->getDatabase()) {
                        return null;
                    }
                    $instance = $this->createPDOMySQL(
                        $this->getLocation(),
                        $this->getDatabase(),
                        $this->getUsername(),
                        $this->getPassword(),
                        $this->getErrorMode(),
                        $this->getCharSet()
                    );
                    $this->setInstance($instance);
                    break;
                default:
                    throw new \Parable\ORM\Exception("Database type was invalid: {$this->getType()}");
            }
        }
        return $this->instance;
    }
954758
public function getSQL(): string
    {
        if ($this->query === null) {
            throw new Exception('Query wasn\'t set');
        }

        if (is_object($this->query)) {
            if (method_exists($this->query, '__toString')) {
                return $this->query->__toString();
            }
        } else {
            return trim($this->query);
        }

        $className = get_class($this->query);
        throw new Exception("Can not use class={$className} as database query because it can't be used as string");
    }
718609
public function getDBInstance()
    {
        if ($this->database === null) {
            $this->database = new MySQLDBImpl($this->config);
        }

        return $this->database;
    }
693728
public function getAdapter()
    {
        if (is_null($this->adapter) || ! $this->adapter instanceof AdapterInterface) {
            $class = '\\Wslim\\Db\Adapter\\' . $this->options['adapter'] . 'Adapter';
            if (!class_exists($class)) {
                throw new DbException('database adapter is not exists:' . $class);
            }
            
            $this->adapter  =   new $class($this->options);
        }
        
        return $this->adapter;
    }
916392
protected function db(): Database
    {
        $conn = app(Pool::class)->getConnection();
        $database = $conn->defaultDatabase;

        return $conn->getRawConnection()->$database;
    }
74870
public static function db()
    {
        self::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        return self::$conn;
    }
1301509
protected function opendb() {
    // Only do one open
    
    if($this->db) {
      return $this->db;
    }
    //echo "$this->host, $this->user, $this->password";
    try {
      $db = @new PDO($this->host, $this->user, $this->password);
    } catch(PDOException $e) {
      $this->errno = $e->getCode();
      $this->error = $e->getMessage();
      throw new SqlException(__METHOD__.  " Connection failed: $this->host", $this);
    }

    $this->db = $db; // set this right away so if we get an error below $this->db is valid

    return $db;
  }
852730
public static function getInstance()
    {
        $sClass = get_called_class();

        if (!isset(self::$_aInstances[$sClass])) {
            self::$_aInstances[$sClass] = new $sClass();
        }

        return self::$_aInstances[$sClass];
    }
1087133
protected function selectDatabase() {
        if ($this->database !== null) {
            try {
                mysql_select_db($this->database, $this->hConnection) || trigger_error(mysql_error($this->hConnection), E_USER_ERROR);
            }
            catch (\Exception $ex) {
                $ex = new DatabaseException($ex->getMessage(), mysql_errno($this->hConnection), $ex);
                throw $ex->addMessage('Can not select database "'.$this->database.'"');
            }
        }
        return $this;
    }
694546
public function getTable()
    {
        if(!($this->_table instanceof DatabaseTableInterface)) {
            $this->_table = $this->getObject($this->_table);
        }

        return $this->_table;
    }
422054
public function getObject()
    {
        //security check
        if (!isset($this->_object)) {
            $condition = array($this->_property => $this->_value);
            $repository = AnDomain::getRepository($this->getIdentifier());

            //check if an entity exiting in the repository with $condition
            if ($data = $repository->find($condition, false)) {
                $this->_object = $data;

                return $this->_object;
            }

            //now time to fetch the object from the database
            //but lets grab all the similar entities all together
            $handle = $this->getIdentifier().$this->_property;
            $values = isset(self::$_values[$handle]) ? self::$_values[$handle] : array();

            if (empty($values)) {
                return;
            }

            $values = AnHelperArray::unique($values);
            $query = $repository->getQuery();
            AnDomainQueryHelper::applyFilters($query, $this->_relationship->getQueryFilters());
            $query->where(array($this->_property => $values));
            $entities = $repository->fetchSet($query);

            //the object must have been fetched with the set
            //in the previous line
            //if the object is still not fetched, then the object
            //doesn't exists in the databse
            $this->_object = $repository->find($condition, false);

            if (!$this->_object) {
                //lets cache the null result to prevent re-fetching
                //the same result
                $query = $repository->getQuery()->where($condition)->limit(1);

                if ($repository->hasBehavior('cachable')) {
                    $repository->emptyCache($query);
                }

                $this->_object = false;

                //if it's a required one-to-one relationship
                //then instantaite a new entity if the entity doesn't exists
                if ($this->_relationship->isOneToOne()) {
                    if ($this->_relationship->isRequired()) {
                        $this->_object = $repository->getEntity(array(
                            'data' => array($this->_property => $this->_value),
                        ));
                    }
                }
            }

            unset(self::$_values[$handle]);
        }

        return $this->_object;
    }
1313797
protected T getObject() {
		final T object;
		if (reusedObject != null) {
			// REUSE THE SAME RECORD AFTER HAVING RESETTED IT
			object = reusedObject;
			object.reset();
		} else
			// CREATE A NEW ONE
			object = (T) database.newInstance(className);
		return object;
	}