YII2批量插入数据代码示例
$field=['userid','nickname','realname','mobile','shengri','title','smsbh','fsmbid','fstime','addtime'];
$row = [];
foreach ($idsarr as $k => $v) :
$usdata = ArrayHelper::getValue($userarr, $v);
$row[] = [
'userid' => $usdata['id'],
'nickname' => $usdata['nickname'],
'realname' => $usdata['realname'],
'mobile' => $usdata['mobile'],
'shengri' => $usdata['shengri'],
'title' => $mbdata['title'],
'smsbh' => $mbdata['smsbh'],
'fsmbid' => $mbdata['id'],
'fstime' => $fstime,
'addtime' => time(),
];
endforeach;
Yii::$app->db->createCommand()->batchInsert(SmstaskModel::tableName(), $field, $row)->execute();
后端用SWOFT做的小程序API案例 《知了来客》http://www.zllaike.com
后端用SWOFT做的小程序API案例《我家有活动》http://www.wjyhd.com
网友评论