public function getCandidateByUserId($userId) { $id = intval($userId); $req = $this->db->prepare('SELECT * FROM candidates WHERE userId = :id'); $req->execute(array('id' => $id)); $res = $req->fetch(); $candidate = Candidate::getModel($res); $req = $this->db->prepare('SELECT * FROM educations WHERE cvId = :id'); $req->execute(array('id' => $candidate->cv->id)); $res = $req->fetchAll(); $candidate->cv->educations = Education::getModels($res); $req = $this->db->prepare('SELECT * FROM professionalexperiences WHERE cvId = :id'); $req->execute(array('id' => $candidate->cv->id)); $res = $req->fetchAll(); $candidate->cv->professional_experiences = ProfessionalExperience::getModels($res); return $candidate; }