首页 > 其他 > 详细

yii2 锁定时间段 添加数据

时间:2020-06-16 10:33:54      阅读:47      评论:0      收藏:0      [点我收藏+]
public function actionSeven()
{
// var_dump(date("Y-m-d",1591804800));die;
// $model = $this->modelClass::find()
// ->select(‘created_at‘)->all();
$time = date(‘Y-m-01‘,strtotime(‘-1 month‘));
$times = strtotime($time);
$model = date(‘Y-m-t‘,strtotime(‘-1 month‘));
$models = strtotime($model);
$res = $this->modelClass::find()
->join(‘left join‘,‘rf_hb_ledger_files b‘,‘b.id=rf_hb_ledger_pro.ledger_id‘)
->select(‘rf_hb_ledger_pro.*‘)
// ->where([‘b.id‘=>59])
->andFilterWhere([‘>‘,‘date‘,$times])
->andFilterWhere([‘<‘,‘date‘,$models])
->asArray()
->all();
$now_time = strtotime(date("Y-m-d",time()));
foreach ($res as &$v){
unset($v[‘id‘]);
$v[‘created_at‘] = $v[‘updated_at‘] = $now_time;
}
$field = array_keys($res[0]);
$res = Yii::$app->db->createCommand()
->batchInsert(HbLedgerPro::tableName(),$field,$res)
->execute();//进行批量插入数据
return $res;
}

yii2 锁定时间段 添加数据

原文:https://www.cnblogs.com/weiylong/p/13139230.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!