E
E
evilelf2015-01-01 18:42:23
Yii
evilelf, 2015-01-01 18:42:23

How to make multiple update or insert in Yii1?

Hello.
Given :

  1. yii1.1.15
  2. Table with columns id, user_id, meta_key, meta_val

There was a need to make a multiple addition of records to the table with user_id == 3, but if there is a row with an equal meta_key, then it needs to be updated.
Question : how to implement it correctly?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
evilelf, 2015-03-06
@evilelf

With createMultipleInsertCommand

V
Vladlen Grachev, 2015-01-01
@gwer

Tabular input
Manual on the link is quite abstract, but conveys the essence. Going through the data, look at the meta_key and determine whether you need to update the record or add it. Transactions can be used to avoid partial processing.

P
Pavel Gogolinsky, 2015-01-02
@gogolinsky

yii has an updateall function. She is best suited for this task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question