<?php

mb_internal_encoding('utf-8');
error_reporting(-1);

class Student
{
	public $firstName;
	public $lastName;
	public $sex;
	public $section;
	public $email;
	public $year;
	public $exams;
	public $isLocal;

	public function __construct(Array $student) {
		$this->firstName = $student['firstName'];
		$this->lastName = $student['lastname'];
		$this->sex = $student['sex'];
		$this->section = $student['section'];
		$this->email = $student['email'];
		$this->year = $student['year'];
		$this->exams = $student['exams'];
		$this->isLocal = $student['isLocal'];
	}

	/* Тут еще будет функция для проверки полей на валидность и возвращать юзеру данны где ошибка */
}

class StudentMapper 
{
	protected $db;

	public function __construct(PDO $db){
		$this->db = $db;
	}

	public function saveStudent(Student $student){
		$STH = $this->db->prepare("INSERT into students (firstName, lastName, sex, section, email, year, exams, isLocal) values (?, ?, ?, ?, ?, ?, ?, ?);");
		$STH = $STH->execute($student);
	}
}

$person = new Student($_POST);
$SAT = new PDO('mysql:host=localhost;dbname=sat', 'root', '');
$table = new StudentMapper($SAT);
$table->saveStudent($person);

?>