Even if you do use Moodle webservices (which I agree you definitely should be doing here), you may struggle with translating some of the concepts onto a Moodle system.
For example, 'teacher_id' - that would imply there is some sort of relationship in the external system between students and teachers - in Moodle, the closest I can think of would be a student enrolled on a course and a teacher also enrolled on a course. I don't know what 'special_id' is, so you'd have to explain more, or figure out for yourself what that would mean in Moodle. In Moodle terms, a 'role' is only relevant for a single course, not the whole site - a user can be a 'teacher' on one course, but a 'student' on another.
For example, 'teacher_id' - that would imply there is some sort of relationship in the external system between students and teachers - in Moodle, the closest I can think of would be a student enrolled on a course and a teacher also enrolled on a course. I don't know what 'special_id' is, so you'd have to explain more, or figure out for yourself what that would mean in Moodle. In Moodle terms, a 'role' is only relevant for a single course, not the whole site - a user can be a 'teacher' on one course, but a 'student' on another.