D
D
ddddd tttt2018-02-05 08:56:42
Yii
ddddd tttt, 2018-02-05 08:56:42

Yii2 how to do multiple inserts/deletions/updates?

How to select, insert, delete, update data without a loop? And how to exclude updating of fields which have not changed?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
ivankomolin, 2018-02-07
@pashaa

There is a batch insert in yii2: www.yiiframework.com/doc-2.0/yii-db-command.html#b...
It can be used for multiple inserts
For multiple updates, you can use it, with some modifications (adding ON DUPLICATE KEY UPDATE)
But about mass deletion, probably just IN, like this: ->where(['IN', 'id', $ids])

M
Michael, 2018-02-16
@springimport

Regular insert (batch update):
I can not find confirmation, but it seems to me that the transaction will allow you to work with the cycle without problems.
Inserting 10,000 records in one transaction?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question