query builder for update

Hi everyone,

consider a scenario like this:

class m170418_121222_add_latitude_longitude extends Migration


    public function safeUp()


        $this->addColumn('addr', 'lat', $this->double()->notNull());

        $this->addColumn('addr', 'lng', $this->double()->notNull());

        $this->createIndex('idx_addr_lat_lng', 'addr', ['lat', 'lng']);


        $faker = \Faker\Factory::create();

        $idQuery = (new \yii\db\Query())->select('id')->from('addr');

        $updateQuery = $this->db->createCommand('UPDATE addr SET lat=:lat, lng=:lng WHERE id=:id');

        foreach ($idQuery->each() as $row)



                ':lat' => $faker->latitude,

                ':lng' => $faker->longitude,

                ':id' => intval($row['id']),





Would it be possible to do the same using the query builder? I’d like to take advantage of the column quoting capabilities and just like the sytax in general. I tried to use QueryBuilder::update and Command::update, but it seems as if they haven’t been designed to support that use case.

Command::update won’t bind the condition parameter, QueryBuilder::update insists on params right away, without giving me the possibility to bind different ones every time I execute the query.

Am I missing something, is there another function I could look into, am I using it the wrong way, or is there simply nothing for that specific usecase?