conn->createQuery() ->from('semester') ->where("status = '1'") ->limit(1) ->query() ->read(); } public function getSemester($semid){ return $this->conn->createQuery() ->from('semester') ->where("semester_id = {$semid}") ->limit(1) ->query() ->read(); } public function getCodeByExamId($examId){ $code = 0; $sql = "select s.status,s.refer_code from exam e join semester s on e.semester_id = s.semester_id where e.exam_id = '{$examId}'"; $data = $this->conn->createQuery($sql)->queryRow(); if($data && $data['status'] != 1){ $code = $data['refer_code']?$data['refer_code']:0; } return $code; } }