dev-master
9999999-devYii2 database tools
MIT
The Requires
by Melnikov Ruslan
database extension yii2
Wallogit.com
2017 © Pedro Peláez
Yii2 database tools
Batch insert into database., (*1)
, (*2)
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
php composer.phar require --prefer-dist mrssoft/yii2-db "*"
or add, (*5)
"mrssoft/yii2-db": "*"
to the require section of your composer.json file., (*6)
$batch = new DbBatch();
$batch->add([
'field1' => $value1,
'field2' => $value2,
]);
$batch->add([
'field1' => $value1,
'field2' => $value2,
], $key)
$batch->addUnique([
'field1' => $value1,
'field2' => $value2,
]);
$bool = $batch->insert('{{%table}}', true);
$bool = $batch->replace('{{%table}}');
$batch = new DbBatch([
'maxItemsInQuery' => 1000,
'table' => '{{%table}}',
'truncate' => true,
'command' => DbBatch::COMMAND_INSERT
]);
$batch->add([
'field1' => $value1,
'field2' => $value2,
], $key);
$batch->update([
'field1' => $value3,
'field2' => $value4,
], $key);
$count = $batch->getCount();
$keys = $batch->getKeys();
$element = $batch->get($key);
$data = $batch->getData();
$batch->setData($data);
$bool = $batch->execute();
Yii2 database tools
MIT
database extension yii2