public function saveOperator($realName, $userName, $userPwd, $roles, $teacher) { $instId = session('instId'); try { $operator = new \Home\Model\OperatorModel(); $operator->startTrans(); $operatorId = $operator->addOperator($instId, $userName, $userPwd, 0, $realName, $teacher); $roleIds = explode('|', $roles); for ($i = 0; $i < count($roleIds); $i++) { $operator->addOperatorAndRoleRela($operatorId[0]['operator_id'], (int) $roleIds[$i]); } $operator->commit(); $data = "true"; } catch (Exception $e) { $operator->rollback(); $data = "false"; } $this->ajaxReturn($data); }