lithium\data\Model::connection()

public static method

Gets the connection object to which this model is bound. Throws exceptions if a connection isn't set, or if the connection named isn't configured.

Returns

object

Returns an instance of lithium\data\Source from the connection configuration to which this model is bound.

Source

	public static function &connection() {
		$self = static::object();
		$connections = $self->_classes['connections'];
		$name = isset($self->_meta['connection']) ? $self->_meta['connection'] : null;

		if ($conn = $connections::get($name)) {
			return $conn;
		}
		$class = get_called_class();
		$msg = "The data connection `{$name}` is not configured for model `{$class}`.";
		throw new ConfigException($msg);
	}