What I did
I am inserting bulk data in table as follows:
if(count($bulkInsertArray)>0){
$columnNameArray=['columnName1','columnName2','columnName3'];
// below line insert all your record and return number of rows inserted
$insertCount = Yii::$app->db->createCommand()
->batchInsert(
$tableName, $columnNameArray, $bulkInsertArray
)
->execute();
}
REF: Insert multiple data into database in Yii 2
and here insert working fine.
What I want:
Now My question is can we do something like if here columnName1 is private key and if we are passing null value for that column then perform insert operation otherwise perform update operation.
Same concept working in CAKEPHP.
I am using YII2.