lithium\data\Source::isConnected()

public method

Checks the connection status of this data source. If the 'autoConnect' option is set to true and the source connection is not currently active, a connection attempt will be made before returning the result of the connection status.

Parameters

  • array $options

    The options available for this method:

    • 'autoConnect': If true, and the connection is not currently active, calls connect() on this object. Defaults to false.

Returns

boolean

Returns the current value of $_isConnected, indicating whether or not the object's connection is currently active. This value may not always be accurate, as the connection could have timed out or otherwise been dropped by the remote resource during the course of the request.

Source

	public function isConnected(array $options = []) {
		$defaults = ['autoConnect' => false];
		$options += $defaults;

		if (!$this->_isConnected && $options['autoConnect']) {
			try {
				$this->connect();
			} catch (NetworkException $e) {
				$this->_isConnected = false;
			}
		}
		return $this->_isConnected;
	}