Answer the question
In order to leave comments, you need to log in
How to properly create a prepared query to add multiple values in yii2?
Such a request works correctly, I add the data in a cycle, but this is not the best option, because every request is parsed. How to insert an array of values. I use other methods - I get errors.
Yii::$app->db->createCommand()->insert('post_tag', [
'post_id' => $postId,
'tag_id' => $tag,
])->execute();
Answer the question
In order to leave comments, you need to log in
Yii::$app->db->createCommand()->batchInsert('user', ['name', 'age'], [
['Tom', 30],
['Jane', 20],
['Linda', 25],
])->execute();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question