当前位置: 首页>>代码示例>>PHP>>正文


PHP CUtil::formArrayFormatting方法代码示例

本文整理汇总了PHP中CUtil::formArrayFormatting方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtil::formArrayFormatting方法的具体用法?PHP CUtil::formArrayFormatting怎么用?PHP CUtil::formArrayFormatting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUtil的用法示例。


在下文中一共展示了CUtil::formArrayFormatting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateTerm

 public function updateTerm($termid, $postArr, $valArr = null)
 {
     $retArr = array('status' => 0, 'message' => '数据不合法', 'term' => null);
     $postArr = $this->removeArrayNull($postArr);
     if (!empty($valArr)) {
         if (empty($valArr['val'])) {
             $retArr['message'] = '指标数据不合法';
             return $retArr;
         }
     }
     //数据检查
     if (empty($postArr) || !$termid) {
         $retArr['message'] = '数据不合法';
         // return $retArr;
     }
     $old = $this->getTerm($termid);
     // print_r($old);
     if (!$old) {
         $retArr['message'] = 'term不存在!';
         return $retArr;
     }
     $postArr['utime'] = date("Y-m-d H:i:s");
     //end 数据检查
     if ($valArr) {
         $valueArr = CUtil::formArrayFormatting($valArr);
         foreach ($valueArr as $k => &$val) {
             if (empty($val['val'])) {
                 unset($valueArr[$k]);
                 continue;
             }
             $val = $this->removeArrayNull($val);
         }
     }
     $ok = $this->updateData($this->tTerm, $postArr, $termid);
     // var_dump(CUtil::IsFalse($ok));
     if (!CUtil::IsFalse($ok)) {
         $term = $this->getTerm($termid);
         //更新参考值=====================================
         if ($valArr && !empty($valueArr)) {
             $_wh_ = array('termid' => $termid);
             $oldValArr = $this->getVals(null, $_wh_, array('only_data' => true, 'keyas' => 'id', 'aggregated' => true, 'limit' => 1000));
             $this->deleteData($this->tVal, $_wh_, 1000);
             $sorter = 127;
             foreach ($valueArr as $r0003) {
                 $r0003['termid'] = $termid;
                 $r0003['sorter'] = $sorter;
                 // $r0003['ctime']   = date("Y-m-d H:i:s");
                 $_old_id = intval($r0003['id']);
                 if (0 == $_old_id) {
                     unset($r0003['id']);
                     //重要
                 } else {
                     $r0003['id'] = $_old_id;
                 }
                 // print_r($r0003);
                 if (isset($oldValArr[$_old_id])) {
                     $r0003 = array_merge($oldValArr[$_old_id], $r0003);
                 }
                 // print_r($r0003);
                 $this->addAtom($this->tVal, $r0003);
                 $sorter--;
             }
         }
         //更新参考值==================================end
         $retArr['term'] = $term;
         $retArr['status'] = 1;
         $retArr['message'] = '更新成功';
     }
     return $retArr;
 }
开发者ID:MedicalProjectto,项目名称:medical,代码行数:70,代码来源:MTerm.php

示例2: appendDoctor

 public function appendDoctor($projectid, $piid, $doctorArr, $othArr = array(), $overwrite = false)
 {
     $logfile = 'MProject';
     if (empty($doctorArr)) {
         CLog::WriteLog(array('msg' => '参数不完整', 'doctorArr' => $doctorArr), $logfile);
         return false;
     }
     $project = $this->getProject($projectid);
     if (!$project) {
         CLog::WriteLog(array('msg' => '项目不存在', 'projectid' => $projectid), $logfile);
         return false;
     }
     $MUser = $this->LoadApiModelMedical('user');
     $docArr = $this->fieldAsKey(CUtil::formArrayFormatting($doctorArr, 0), 'doctorid');
     $docid_arr = $doctorArr['doctorid'];
     $userArr = $MUser->getUsers($docid_arr, array('role' => 10), array('limit' => count($docid_arr), 'only_data' => true));
     if (empty($userArr)) {
         CLog::WriteLog(array('msg' => '用户不存在', 'docid_arr' => $docid_arr), $logfile);
         return false;
     }
     $addArr = array();
     //准备要加的医生记录(多条)
     foreach ($userArr as $user) {
         $doctorid = $user['id'];
         if (!isset($docArr[$doctorid])) {
             continue;
         }
         $row = array('piid' => isset($docArr[$doctorid]['piid']) ? $docArr[$doctorid]['piid'] : $piid, 'doctorid' => $user['id'], 'projectid' => $projectid, 'hospitalid' => $user['hospitalid'], 'username' => $user['username'], 'ctime' => date("Y-m-d H:i:s"));
         if (!empty($othArr['num_goal'])) {
             $row['num_goal'] = $othArr['num_goal'];
         }
         $addArr[] = $row;
     }
     $oldDocs = $this->getAppends('doctor', array('projectid' => $projectid, 'piid' => $piid), array('no_hospital' => 1, 'only_data' => true, 'limit' => 1000));
     // print_r($addArr);
     if ($overwrite) {
         $this->deleteData($this->tPDoctor, array('projectid' => $projectid), 1000);
     }
     // $ok = $this->addMore($this->tPDoctor, $addArr, array('ignored'=>true,'replaced'=>true));
     CLog::WriteLog(array('msg' => '执行replaceData', 'addArr' => $addArr), $logfile);
     $ok = $this->replaceData($this->tPDoctor, $addArr, 'projectid,doctorid');
     //验证医生数量
     $piAppend = $this->getAppends('pi', array('projectid' => $projectid, 'piid' => $piid), array('no_hospital' => 1, 'only_data' => true));
     //pi信息,主要是查询num_goal
     if (!isset($piAppend[0])) {
         CLog::WriteLog(array('msg' => 'piAppend信息不存在', 'piAppend' => $piAppend), $logfile);
         return false;
     }
     $piAppend = $piAppend[0];
     $num_goal_pi = $piAppend['num_goal'];
     $piDoctors = $this->getAppends('doctor', array('projectid' => $projectid, 'piid' => $piid), array('no_hospital' => 1, 'only_data' => true, 'limit' => 1000));
     //pi的所有医生信息,主要是查询num_goal
     $num_goal_arr = $this->getArrayColumn($piDoctors, 'num_goal');
     $num_goal_of_docs = array_sum($num_goal_arr);
     if ($num_goal_of_docs > $num_goal_pi) {
         foreach ($addArr as $wh) {
             //把原的一行作为条件去删除
             $this->deleteData($this->tPDoctor, $wh);
         }
         if ($oldDocs) {
             $this->replaceData($this->tPDoctor, $oldDocs, 'id');
             //还原
         }
         CLog::WriteLog(array('msg' => 'num_goal数量过大', 'num_goal_of_docs' => $num_goal_pi), $logfile);
         $ok = false;
     }
     //end 验证医生数量
     //获取项目下医生的个数
     $num_doctor = $this->getCount($this->tPDoctor, array('projectid' => $projectid));
     $this->updateProject($projectid, array('num_doctor' => $num_doctor));
     //end 获取项目下医生的个数
     //获取pi下的医生数
     $num_doctor = $this->getCount($this->tPDoctor, array('projectid' => $projectid, 'piid' => $piid));
     $this->updateData($this->tPPi, array('num_doctor' => $num_doctor), array('projectid' => $projectid, 'piid' => $piid));
     //end 获取pi下的医生数
     //end 获取病人的个数
     return $ok;
 }
开发者ID:MedicalProjectto,项目名称:medical,代码行数:78,代码来源:MProject.php

示例3: saveTplReport


//.........这里部分代码省略.........
                                         $reportid = $old['id'];
                                     }
                                     break;
                                 case -7:
                                     if(CTime::IsWeek($utime)){//是本周
                                         $reportid = $old['id'];
                                     }
                                     break;
                                 case -30:
                                     if(CTime::IsMonth($utime)){//是本月
                                         $reportid = $old['id'];
                                     }
                                     break;
                                 case -365:
                                     if(CTime::IsYear($utime)){//是当年
                                         $reportid = $old['id'];
                                     }
                                     break;
                             }*/
         }
     }
     //end 业务上的数据检查
     CLog::WriteLog(array('msg' => 'commit数据', 'reportid' => $reportid, 'periodid' => $periodid, 'postArr' => $postArr, 'details' => $details), $logfile);
     if ($reportid) {
         $ok = $this->updateData($this->tReport, $postArr, $reportid);
     } else {
         $postArr['ctime'] = $postArr['utime'];
         $ok = $reportid = $this->addAtom($this->tReport, $postArr);
     }
     if (CUtil::NoFalse($ok)) {
         $report = $this->getTplReport($reportid, null, array('aggregated' => true));
         //更新报告值=====================================
         if ($details) {
             $valueArr = CUtil::formArrayFormatting($details, 0);
             CLog::WriteLog(array('msg' => 'commit值', 'valueArr' => $valueArr), $logfile);
             $tpl_did_arr = $this->getArrayColumn($valueArr, 'detailid');
             $detailArr = $this->getData($this->tTdetail, array('id in' => $tpl_did_arr), array('limit' => count($tpl_did_arr), 'keyas' => 'id'));
             $termid_arr = $this->getArrayColumn($detailArr, 'termid');
             $MTerm = $this->LoadApiModelMedical('term');
             $termArr = $MTerm->getTerms($termid_arr, null, array('limit' => count($termid_arr), 'only_data' => true, 'keyas' => 'id', 'fields' => '^ctime,utime'));
             // print_r($termArr);
             foreach ($valueArr as $k => &$r0005) {
                 if (empty($r0005['detailid'])) {
                     unset($valueArr[$k]);
                     continue;
                 }
                 //检查detailid在数据库中是否存在,不存在则删除
                 if (!isset($detailArr[$r0005['detailid']])) {
                     unset($valueArr[$k]);
                     continue;
                 }
                 //检查指标是否在指标库中存在,存在则将termid及输入类型存放tpl_report_detail中
                 $detail = $detailArr[$r0005['detailid']];
                 if (isset($termArr[$detail['termid']])) {
                     $term = $termArr[$detail['termid']];
                     $r0005['termid'] = $term['id'];
                     $r0005['itype'] = $term['itype'];
                     $r0005['vtype'] = $term['vtype'];
                 }
                 $r0005 = $this->removeArrayNull($r0005);
             }
             if (!empty($valueArr)) {
                 $_wh_ = array('reportid' => $reportid);
                 //查询详情(tpl_detail)的条件
                 $oldValArr = $this->getMore($this->tRdetail, $_wh_, array('only_data' => true, 'keyas' => 'id', 'aggregated' => true, 'limit' => 1000));
                 // $this->deleteData($this->tRdetail, $_wh_, 1000);
开发者ID:MedicalProjectto,项目名称:medical,代码行数:67,代码来源:MTpl.php


注:本文中的CUtil::formArrayFormatting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。