<?php
class a
{
protected static $Senior = [1, 2, 3];
protected static $NoSenior = [13, 14, 15, 16, 17, 18, 19;
/**
* 获取所有在职老师的id
* 根据在职老师去查所匹配的条件
* 根据条件取跟新新的
*/
function run()
{
//获取所有在职老师的id
$sql = "SELECT t.teacher_id FROM teacher t LEFT JOIN teacher_ext te on t.teacher_id = te.id WHERE te.job_status = 1";
$list = M()->all();
//sleep(10);
foreach ($list as $teacher_id) {
//$teacher_id = 22171;
$sql = "SELECT t.teacher_id,t.race_type,lm.is_leader,ttgr.grade_id FROM teacher t
LEFT JOIN 表 te on 条件
LEFT JOIN 表 lm on 条件
LEFT JOIN 表 ttgr on 条件
WHERE t.teacher_id = ? ";
$teacherDate = M()->query($sql, $teacher\_id)->all();//查询
$endRaceType = $this->tdate($teacherDate);
$res = $this->insertDate($endRaceType, $teacher\_id\['teacher\_id'\]);
}
}
/\*\*
\* 获取老师的所有类型;
\* @param $teacherDate
\* @return array
\*/
public function tdate($teacherDate)
{
$raceType = \[\];
foreach ($teacherDate as $val) {
if ($val\['is\_leader'\] == 1) {
if (in\_array($val\[''\], self::Senior)) {
} else {
}
} else {
if (in\_array($val\[''\], self::$Senior)) {
} else {
}
//组合所有的授课类型
$raceType\[\] = $teacherRaceType;
}
//合并所有授课类型到一个数组,并去除重复的授课类型;
$race = \[\];
for ($i = 0; $i < count($raceType); $i++) {
$middle = array\_merge($race, $raceType\[$i\]);
$race = $middle;
}
$endRaceType = array\_unique($race);
return $endRaceType;
}
/\*\*
\* 存入数据库;
\* @param $endRaceType
\* @param $teacher\_id
\*/
public function insertDate($endRaceType, $teacher\_id)
{
foreach ($endRaceType as $v) { //添加到数据库
$m = M()->begin();
try {
M()->insert(\['teacherId' => $teacher\_id, 'raceType' => $v\]);
$m->end(true);
} catch (\\Exception $e) {
$m->end(false);
MSVC::log( $e->getMessage());
}
}
sleep(10);
}
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章