Get database connection

I access my database using activeRecords.
I want to make a simple query in one of my action methods in the controller class like this:

$con = ?????
    foreach ( $dataProvider->data as $row) {
         $sql = "DELETE FROM mytable WHERE Id = ".$row->id;
         if (mysqli_query($con,$sql) ) echo $row["Id"]." deleted.<br>";

How can I get the current database connection?

Sorry for this beginner question. It’s a long time ago that I used yii …

Did you try “db” (default). Defined in config.

If you want to make a simple query, you should use this

$sql = "DELETE FROM mytable WHERE Id = ".$row->id;

This query is very very danger!!!.. SQL Injection