我做了什么
我在表中插入批量数据,如下所示:
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();
}
在这里插入工作正常。
我想要的是:
现在我的问题是,如果这里的 columnName1 是私钥,并且如果我们为该列传递空值,那么我们是否可以执行插入操作,否则执行更新操作。
在 CAKEPHP 中工作的相同概念。
我正在使用 YII2。