dev-master
9999999-devSimple Behavior INSERT ON DUPLICATE KEY UPDATE or INSERT IGNORE
MIT
The Requires
by Egor Kozhemin
extension yii2
Simple Behavior INSERT ON DUPLICATE KEY UPDATE or INSERT IGNORE
Simple Behavior INSERT ON DUPLICATE KEY UPDATE or INSERT IGNORE, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require kozhemin/yii2-insert-update-behavior:dev-master
or add, (*4)
"kozhemin/yii2-insert-update-behavior": "dev-master"
to the require section of your composer.json
file., (*5)
This behavior allows you to create queries for INSERT ON DUPLICATE KEY UPDATE or INSERT IGNORE, (*6)
For example:, (*7)
Attach a new behavior to your model, (*8)
public function behaviors() { return[ \kozhemin\dbHelper\InsertUpdate::className(), ]; }
usage, (*9)
$dataInsert = [ ['title text', 'description'], ['title2 text', 'description2'], ['title3 text', 'descriptio3'] ]; //Optional column parameter $column = ['title', 'description'];
//INSERT ON DUPLICATE KEY UPDATE $model = new Post(); $model->InsertUpdate($dataInsert, $column)
or, (*10)
//INSERT IGNORE $model = new Post(); $model->insertIgnore($dataInsert, $column)
Simple Behavior INSERT ON DUPLICATE KEY UPDATE or INSERT IGNORE
MIT
extension yii2