yii\db\ActiveRecord::getDb PHP Method

getDb() public static method

By default, the "db" application component is used as the database connection. You may override this method if you want to use a different database connection.
public static getDb ( ) : Connection
return Connection the database connection used by this AR class.
    public static function getDb()
    {
        return Yii::$app->getDb();
    }

Usage Example

 protected function beginTransaction()
 {
     $db = $this->owner->getDb();
     if ($db->getTransaction() === null) {
         $this->transaction = $db->beginTransaction();
     }
 }
All Usage Examples Of yii\db\ActiveRecord::getDb