Trait Yiisoft\ActiveRecord\Trait\CustomConnectionTrait
Trait to implement a custom connection name for ActiveRecord.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| db() | Yiisoft\ActiveRecord\Trait\CustomConnectionTrait | |
| withConnectionName() | Sets the connection name for the ActiveRecord. | Yiisoft\ActiveRecord\Trait\CustomConnectionTrait |
Method Details
| public \Yiisoft\Db\Connection\ConnectionInterface db ( ) |
public function db(): ConnectionInterface
{
if (!empty($this->connectionName)) {
return ConnectionProvider::get($this->connectionName);
}
return parent::db();
}
Sets the connection name for the ActiveRecord.
| public Yiisoft\ActiveRecord\Trait\CustomConnectionTrait withConnectionName ( string $connectionName ) | ||
| $connectionName | string | |
public function withConnectionName(string $connectionName): static
{
$new = clone $this;
$new->connectionName = $connectionName;
return $new;
}
Signup or Login in order to comment.