<?
class Student {
	private $properties;
	function __construct($name, $age, $email){
		$name = strip_tags(trim($name));
		$email = strip_tags(trim($email));
		$age = (int)$age;
		$this->properties = array('name'=>$name, 'age'=>$age, 'email'=>$email);
	}
	function getInfo(){
		return $this->properties;
	}
}
class DataMapper {
	protected $db;
	function __construct($db){
		$this->db = $db;
	}
	function insertIntoDB(Student &$student){
		$query = "INSERT INTO tbl (name, age, email) VALUES (:name, :age, :email)";
		$stmt = $this->db->prepare($query);
		$info = $student->getInfo();
		$stmt->bindParam(':name', $this->db->quote($info['name']));
		$stmt->bindParam(':age', $this->db->quote($info['age']));
		$stmt->bindParam(':email', $this->db->quote($info['email']));
		$stmt->execute();
	}
	function selectFromDB(){
		//***
	}
}
$student = new Student($_POST['name'], $_POST['age'], $_POST['email']);
$db = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$mapper = new DataMapper($db);
$mapper->insertIntoDB($student);