Extends
lithium\core\StaticObject
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 = static::$_classes['connections'];
$name = isset($self->_meta['connection']) ? $self->_meta['connection'] : null;
if ($conn = $connections::get($name)) {
return $conn;
}
throw new ConfigException("The data connection `{$name}` is not configured.");
}