Determines if the connection to the server is active.

@return  boolean  True if connected to the database engine.

@since   1.0
763888
public function connected()
	{
		// Flag to prevent recursion into this function.
		static $checkingConnected = false;

		if ($checkingConnected)
		{
			// Reset this flag and throw an exception.
			$checkingConnected = true;
			die('Recursion trying to check if connected.');
		}

		// Backup the query state.
		$sql      = $this->sql;
		$limit    = $this->limit;
		$offset   = $this->offset;
		$prepared = $this->prepared;

		try
		{
			// Set the checking connection flag.
			$checkingConnected = true;

			// Run a simple query to check the connection.
			$this->setQuery($this->getConnectedQuery());
			$status = (bool) $this->loadResult();
		}
		catch (\Exception $e)
		{
			// If we catch an exception here, we must not be connected.
			$status = false;
		}

		// Restore the query state.
		$this->sql         = $sql;
		$this->limit       = $limit;
		$this->offset      = $offset;
		$this->prepared    = $prepared;
		$checkingConnected = false;

		return $status;
	}
384256
public function connect(): bool
    {
        try {
            $this->checkConnect();
            $this->log('Connect to ' . $this->connect['host']);
            $this->handler = new \PDO(
                $this->connect['type'] . ':host=' . $this->connect['host'] . ';dbname=' . $this->connect['name'],
                $this->connect['user'],
                $this->connect['pass'],
                $this->connect['options']
            );

            foreach ($this->attributes as $attribute => $value) {
                $this->handler->setAttribute($attribute, $value);
            }

            $this->ok();
        } catch (\Exception $e) {
            throw new DbException("Attempt connection to database is failed: {$e->getMessage()}");
        }
        return true;
    }
73207
public function isConnected()
    {
        return ((bool) (is_resource($this->_connection)
                    && (get_resource_type($this->_connection) == 'oci8 connection'
                     || get_resource_type($this->_connection) == 'oci8 persistent connection')));
    }
1138815
protected function isInTransaction()
    {
        $status = $this
            ->getSession()
            ->getConnection()
            ->getTransactionStatus()
            ;

        return (bool) ($status === \PGSQL_TRANSACTION_INTRANS || $status === \PGSQL_TRANSACTION_INERROR || $status === \PGSQL_TRANSACTION_ACTIVE);
    }
834075
function isConnected() {
		try {
			return $this->connection->isOpen();
		} catch (SmtpException $ex) {
			$this->log('EOF caught while checking if connected', 'client');
			$this->close();
		}
		return false;
	}
795440
public function isConnected()
    {
        try {
            return \is_resource($this->connection) && \ftp_rawlist($this->connection, $this->getRoot()) !== false;
        } catch (\ErrorException $e) {
            if (\strpos($e->getMessage(), 'ftp_rawlist') === false) {
                throw $e;
            }

            return false;
        }
    }
462141
public function getConnectionStatus()
    {
        if (!$this->hasHandler()) {
            if ($this->is_closed) {
                return static::CONNECTION_STATUS_CLOSED;
            } else {
                return static::CONNECTION_STATUS_NONE;
            }
        }

        if (@pg_connection_status($this->handler) === \PGSQL_CONNECTION_OK) {
            return static::CONNECTION_STATUS_GOOD;
        }

        return static::CONNECTION_STATUS_BAD;
    }
1203967
public function ping() {

		$canConnect = false;

		foreach ( $this->httpRequests as $httpRequest ) {
			if ( !$httpRequest->ping() ) {
				return false;
			}

			$canConnect = true;
		}

		return $canConnect;
	}
1004917
public function check_connection()
    {
        // Establish connection if it wasn't done yet
        if (!$this->connect_done && !empty($this->options['user'])) {
            return $this->connect(
                $this->options['host'],
                $this->options['user'],
                $this->options['password'],
                $this->options['port'],
                $this->options['ssl']
            );
        }

        return $this->is_connected();
    }
325051
public function ping()
    {
        foreach (class_parents($this) as $parent) {
            if (method_exists($parent, 'ping')) {
                return parent::ping();
            }
        }

        $this->connect();

        try {
            $this->query($this->getDatabasePlatform()->getDummySelectSQL());
            return true;
        } catch (DBALException $e) {
            return false;
        }
    }
26204
public function isConnected()
    {
        return $this->synchronized(function ($self) {
            return $self->applicationState->equals(ApplicationStateKeys::get(ApplicationStateKeys::INITIALIZATION_SUCCESSFUL));
        }, $this);
    }
852437
public function checkConnection() {
        try {
            $st = $this->_conn->query("SELECT 1");
        } catch(\PDOException $pe) {
            if ((strcasecmp($pe->getCode(), 'HY000') !== 0) && !stristr($pe->getMessage(), 'server has gone away'))
                throw $pe;

            if (function_exists('xdebug_start_trace'))
                xdebug_start_trace();

            $this->_resetConnection();
            $this->_connect();
        }

        return true;
    }
731385
public function connect() : bool
    {
        try {
            $connection_string = 'sqlsrv:SERVER=' . $this->configuration['server'] . ';DATABASE=' . $this->configuration['dbname'];
            if (isset($this->configuration['encrypt']) && true === $this->configuration['encrypt']) {
                $connection_string .= ';ENCRYPT=1';
            }
            $this->logger->debug('Connecting to database engine.');
            $this->dbconn = new PDO($connection_string, $this->configuration['username'],
                $this->configuration['password']);
            $this->dbconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $this->logger->debug('Connected to database engine.');
            $this->is_connected = true;
        } catch (\Exception $e) {
            throw new DatabaseConnectionException('MSSQL Connection to <strong>' . $this->configuration['server'] . '</strong> failed!<br>' . $e->getMessage());
        }
        return true;
    }
727109
public function isLoaded(): bool
    {
        return $this->getMethod() !== self::JOIN && $this->getMethod() !== self::LEFT_JOIN;
    }
1297084
public function isAlive()
    {
        if ($this->getStatus() == Aoe_Scheduler_Model_Schedule::STATUS_RUNNING) {
            if (time() - strtotime($this->getLastSeen()) < 2 * 60) { // TODO: make this configurable
                return true;
            } elseif ($this->getHost() == gethostname()) {
                if ($this->checkPid()) {
                    $this
                        ->setLastSeen(strftime('%Y-%m-%d %H:%M:%S', time()))
                        ->save();
                    return true;
                } else {
                    $this->markAsDisappeared(sprintf('Process "%s" on host "%s" cannot be found anymore', $this->getPid(), $this->getHost()));
                    return false; // dead
                }
            } else {
                // we don't know because the task is running on a different server
                return null;
            }
        }
        return false;
    }
633403
public function status()
	{
		try
		{
			$pingRequest = $this->connection->createPing();
			$ping = $this->connection->ping($pingRequest);
			$pong = $ping->getData();
			$alive = false;

			if (isset($pong['status']) && $pong['status'] === "OK")
			{
				return true;
			}
		}
		catch (\Solarium\Exception $e)
		{
			return false;
		}
	}
350492
protected boolean checkConnection()
    {
        super.checkConnection();
        try
        {
            if (_jarConnection!=_connection)
                newConnection();
        }
        catch(IOException e)
        {
            LogSupport.ignore(log,e);
            _jarConnection=null;
        }
        
        return _jarConnection!=null;
    }