登录  注册 退出
苏杭php自学网
记录个人学习过程中碰见的问题和感受
要温柔,也要有屠龙的勇气
本站有学习资源,可自由下载学习资料
  1. 首页 > PHP自学教程 > Yii框架

yii1.1 批量更新 (随机匹配)

作者:苏杭 日期:2021-04-09 18:33:17 点击数:
$sq = "SELECT uname FROM  yyslist where first_department='整形外科'";
$data_l = Yii::app()->db_press->createCommand($sq)->queryAll();

foreach ($data_list as $ke => $va){

   $sui = rand(1,3);
   $doc = rand(0,26);

   if($sui == 1){
       $doctor = $data_l[$doc]['uname'];
   }elseif ($sui == 2){
       $doctor = $data_l[$doc]['uname'].','.$data_l[$doc+1]['uname'];
   }else{
       $doctor = $data_l[$doc]['uname'].','.$data_l[$doc-1]['uname'].','.$data_l[$doc+1]['uname'];
   }

   Yii::app()->db_press->createCommand()->update('ym_baikes',array('doctor_name'=>$doctor), 'id=:id', array(':id'=>$va['id']));
}

die();


随机给


随便看看
QQ在线咨询
电话:
182 7047 6708
交流微信:
su18270476708