Wednesday, March 28, 2018

Yii2 batch update

In batch query method we can retrieve data in batches. We can use batch using yii\db\Query::batch().

Yii2 batch update


$rows = $query->select(['name','email'])
                    ->from('tblName1')
                    ->all();
$columnNames = ['name','email'];
$result = \Yii::$app->db->createCommand()->batchInsert('tblName2', $columnNames, $rows)->execute();

1 comment:

Recent Update

yii2 session handling

use yii\web\Session; $session = Yii::$app->session; // start session $session->open(); // close session $session->close(); ...

Most Search